@agimon-ai/po-help 0.0.0-alpha.62 → 0.0.0-alpha.63

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.
@@ -115,6 +115,20 @@ const AXES = [
115
115
  "domains",
116
116
  "profile"
117
117
  ];
118
+ const OUTCOME_MESSAGE_TYPE = "po-help/self-improve";
119
+ /** One line the agent can pass on to the person without calling operation(). */
120
+ function describeOutcome(operation) {
121
+ const what = operation.axes ? `Refresh ${operation.operationId} (${operation.axes.join(", ")})` : `Reload ${operation.operationId} (${operation.scope} scope)`;
122
+ const tell = "Tell the person the outcome.";
123
+ if (operation.state === "failed") return `${what} failed, nothing changed: ${(operation.error ?? "unknown error").replace(/\.$/u, "")}. ${tell}`;
124
+ const result = operation.result;
125
+ const parts = [
126
+ result?.installed.length ? `installed ${result.installed.join(", ")}` : "",
127
+ result?.removed.length ? `removed ${result.removed.join(", ")}` : "",
128
+ result?.failed.length ? `failed ${result.failed.map((item) => `${item.packageName} (${item.reason})`).join(", ")}, which keep their previous build` : ""
129
+ ].filter(Boolean);
130
+ return `${what} ${operation.state}${parts.length ? `: ${parts.join("; ")}` : ""}. ${tell}`;
131
+ }
118
132
  const DECLARATIONS = `type Scope = 'session' | 'workspace' | 'global';
119
133
  type Axis = 'majorMode' | 'domains' | 'profile';
120
134
  interface PackageFailure { scope: string; packageName: string; stage: string; reason: string; previous?: 'restored' | 'lost' | 'none'; at: string }
@@ -124,13 +138,15 @@ interface Operation {
124
138
  state: 'queued' | 'applied' | 'partial' | 'failed';
125
139
  result?: { installed: string[]; removed: string[]; failed: { packageName: string; reason: string }[] };
126
140
  error?: string;
141
+ /** Why the outcome follow-up could not reach you, when it did not. */
142
+ undelivered?: string;
127
143
  }
128
144
  declare const selfImprove: {
129
145
  /** Packages whose current build failed to load or install, by scope. */
130
146
  plugins(): Promise<{ failures: PackageFailure[] }>;
131
- /** Queues a reload of one scope's packages from disk; check it with operation() in a later exec. global needs confirm: true, after the person agreed. */
147
+ /** Queues a reload of one scope's packages from disk. When it finishes you get a follow-up message with the outcome; operation() returns it too. global needs confirm: true, after the person agreed. */
132
148
  reload(input: { scope: Scope; confirm?: boolean }): Promise<Operation>;
133
- /** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; check it with operation(). */
149
+ /** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; reports its outcome like reload. */
134
150
  refresh(input?: { axes?: Axis[] }): Promise<Operation>;
135
151
  operation(operationId: string): Promise<Operation>;
136
152
  };`;
@@ -145,6 +161,19 @@ function createSelfImproveNamespace(options) {
145
161
  }
146
162
  return operation;
147
163
  };
164
+ const finish = (operation) => {
165
+ remember(operation);
166
+ Promise.resolve(options.admitMessage?.({
167
+ type: OUTCOME_MESSAGE_TYPE,
168
+ text: describeOutcome(operation),
169
+ display: true
170
+ }, "followUp")).catch((error) => {
171
+ remember({
172
+ ...operation,
173
+ undelivered: error instanceof Error ? error.message : String(error)
174
+ });
175
+ });
176
+ };
148
177
  return {
149
178
  name: "selfImprove",
150
179
  summary: "Reload Po's own packages after editing them, or refresh this session's mode, domains and profile config, without restarting. Help mode, main agent only.",
@@ -175,11 +204,11 @@ function createSelfImproveNamespace(options) {
175
204
  options.service.reload({
176
205
  scope: queued.scope,
177
206
  sessionId: options.sessionId
178
- }).then((result) => remember({
207
+ }).then((result) => finish({
179
208
  ...queued,
180
209
  state: result.failed.length === 0 ? "applied" : "partial",
181
210
  result: JSON.parse(JSON.stringify(result))
182
- }), (error) => remember({
211
+ }), (error) => finish({
183
212
  ...queued,
184
213
  state: "failed",
185
214
  error: error instanceof Error ? error.message : String(error)
@@ -199,10 +228,10 @@ function createSelfImproveNamespace(options) {
199
228
  options.service.refresh({
200
229
  sessionId: options.sessionId,
201
230
  axes: queued.axes
202
- }).then(() => remember({
231
+ }).then(() => finish({
203
232
  ...queued,
204
233
  state: "applied"
205
- }), (error) => remember({
234
+ }), (error) => finish({
206
235
  ...queued,
207
236
  state: "failed",
208
237
  error: error instanceof Error ? error.message : String(error)
@@ -385,7 +414,8 @@ function createHelpServerSession(host, packageFailures = () => [], selfImprove)
385
414
  sessionId: host.context.sessionId,
386
415
  service: selfImprove,
387
416
  failures: packageFailures,
388
- assertActive: assertHelpActive
417
+ assertActive: assertHelpActive,
418
+ admitMessage: host.context.session.admitMessage?.bind(host.context.session)
389
419
  });
390
420
  const activity = host.registerActivity({
391
421
  when: _agimon_ai_po_core_help.PO_HELP_WHEN,
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","names":["Type","defineTool","HELP_WHEN","HELP_WHEN","packageResourcePath","readPackageResource","defineMinorMode","PO_CODEMODE_SERVICE","readPoCodemode","serverMinorModes","readPoPackageHealth","readPoSelfImprove","defineRoot","runtime","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","composeRootHooks","commandPoHelp","resourceCodemodeHowToSelfImprove","resourcePoDevelopCodemodePlugin","resourcePoDevelopNativeExtension","resourcePoHelp","resourcePoUseChatgptInstructions","resourcePoUseHelp","toolHelpStatus"],"sources":["../../src/constants/help.ts","../../src/schemas/diagnostics.ts","../../src/services/helpStatus/index.ts","../../src/services/selfImproveNamespace/index.ts","../../src/services/helpServerSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/help_status.server.ts","../../generated/server.ts"],"sourcesContent":["export const HELP_COMMAND_NAME = 'po-help';\nexport const HELP_COMMAND_DESCRIPTION = 'Toggle Help guidance and read-only support diagnostics';\nexport const HELP_MODE_ID = 'help';\nexport const HELP_PACKAGE_SOURCE = '@agimon-ai/po-help';\nexport const HELP_SKILL = {\n name: 'help-how-to-help',\n description:\n 'Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.',\n} as const;\nexport const HELP_GUIDANCE =\n 'Help mode is active. Read help-how-to-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.';\nexport const HELP_STATUS_TOOL_NAME = 'help_status';\nexport const HELP_STATUS_TOOL_DESCRIPTION =\n 'Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.';\nexport const HELP_STATUS_LIMIT = 128;\n\nexport const HELP_CHATGPT_SKILL = {\n name: 'help-how-to-chatgpt-instructions',\n description:\n \"Print a paste-ready ChatGPT project instruction (at most 8,000 characters) that routes code-mode work through this session's MCP tools and condenses every AGENTS.md rule. Writes no files.\",\n} as const;\n\nexport const HELP_CODEMODE_SKILL = {\n name: 'help-how-to-codemode-plugin',\n description:\n 'Add code-mode support to a Po package: contribute a namespace to exec and discover, replace the direct tool it supersedes, and ship the skill that teaches agents to use it.',\n} as const;\n\nexport const HELP_NATIVE_SKILL = {\n name: 'help-how-to-native-extension',\n description:\n \"Add or change a Po package's phone UI (.native files, native templates) so it mirrors the cockpit, passes the native build, and is approved and verified before it ships.\",\n} as const;\n\nexport const HELP_SELF_IMPROVE_SKILL = {\n name: 'codemode-how-to-self-improve',\n description:\n \"Reload Po's own packages after you edit them, without restarting Po or reopening the session. Use in Help mode after changing a plugin's source or build, or after adding or removing a package.\",\n} as const;\n","import { Type } from 'typebox';\n\nexport const helpStatusParameters = Type.Object({}, { additionalProperties: false });\n","import type { PoHeadlessCapabilitySnapshot } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN, type PoPackageFailureRecord } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverPlugin';\n\nimport {\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_STATUS_LIMIT,\n HELP_STATUS_TOOL_DESCRIPTION,\n HELP_STATUS_TOOL_NAME,\n} from '../../constants/help';\nimport { helpStatusParameters } from '../../schemas/diagnostics';\nimport type { HelpStatusReport } from './type';\n\n/** `packageFailures`: the host's failed global and workspace packages; they never degrade Help itself. */\nexport function serverHelpStatus(\n snapshot: PoHeadlessCapabilitySnapshot,\n enabled: boolean,\n packageFailures: readonly PoPackageFailureRecord[] = [],\n): HelpStatusReport {\n const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.['minor-mode'] === HELP_MODE_ID);\n const skills = entries.filter((entry) => entry.kind === 'skill');\n const tools = entries.filter((entry) => entry.kind === 'tool');\n const diagnostics = entries\n .filter((entry) => enabled && entry.reason && entry.reason !== 'inactive')\n .map((entry) => ({ source: entry.source, code: `HELP_${entry.reason!.replaceAll('-', '_').toUpperCase()}` }));\n const ready = snapshot.ready;\n return {\n activation: !enabled ? 'inactive' : !ready ? 'activating' : diagnostics.length ? 'degraded' : 'active',\n ready,\n revision: snapshot.revision,\n counts: {\n skills: ready ? skills.filter((entry) => entry.active && entry.discoverable).length : null,\n tools: tools.filter((entry) => entry.active).length,\n },\n skills: skills.slice(0, HELP_STATUS_LIMIT).map(({ name, source, active, discoverable, reason }) => ({\n name,\n source,\n active: active && discoverable,\n ...(reason ? { reason } : {}),\n })),\n tools: tools\n .slice(0, HELP_STATUS_LIMIT)\n .map(({ name, source, active, reason }) => ({ name, source, active, ...(reason ? { reason } : {}) })),\n diagnostics: diagnostics.slice(0, HELP_STATUS_LIMIT),\n packages: enabled ? packageFailures.slice(-HELP_STATUS_LIMIT) : [],\n truncated:\n skills.length > HELP_STATUS_LIMIT ||\n tools.length > HELP_STATUS_LIMIT ||\n diagnostics.length > HELP_STATUS_LIMIT ||\n (enabled && packageFailures.length > HELP_STATUS_LIMIT),\n };\n}\n\nexport function helpStatusDetail(report: HelpStatusReport): string {\n return `${report.counts.skills ?? 'pending'} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? ' (diagnostics available)' : ''}`;\n}\n\nexport function createHelpStatusTool(\n inspect: () => HelpStatusReport | Promise<HelpStatusReport>,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: HELP_STATUS_TOOL_NAME,\n description: HELP_STATUS_TOOL_DESCRIPTION,\n parameters: helpStatusParameters,\n when: HELP_WHEN,\n promptGuidelines: [HELP_GUIDANCE],\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const report = await inspect();\n signal.throwIfAborted();\n authorize(execution.signal);\n return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }], details: report };\n },\n });\n}\n","import type { PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessRefreshAxis } from '@agimon-ai/po-core/headless';\n\nimport type { SelfImproveNamespaceOptions, SelfImproveOperation, SelfImproveScope } from './type';\n\n/** Finished operations kept for `operation(id)`; older ones are forgotten first. */\nconst MAX_OPERATIONS = 20;\nconst SCOPES: readonly SelfImproveScope[] = ['session', 'workspace', 'global'];\nconst AXES: readonly PoHeadlessRefreshAxis[] = ['majorMode', 'domains', 'profile'];\n\nconst DECLARATIONS = `type Scope = 'session' | 'workspace' | 'global';\ntype Axis = 'majorMode' | 'domains' | 'profile';\ninterface PackageFailure { scope: string; packageName: string; stage: string; reason: string; previous?: 'restored' | 'lost' | 'none'; at: string }\ninterface Operation {\n operationId: string; scope: Scope; axes?: Axis[];\n /** partial: applied, but some packages failed and keep their previous build when they had one. */\n state: 'queued' | 'applied' | 'partial' | 'failed';\n result?: { installed: string[]; removed: string[]; failed: { packageName: string; reason: string }[] };\n error?: string;\n}\ndeclare const selfImprove: {\n /** Packages whose current build failed to load or install, by scope. */\n plugins(): Promise<{ failures: PackageFailure[] }>;\n /** Queues a reload of one scope's packages from disk; check it with operation() in a later exec. global needs confirm: true, after the person agreed. */\n reload(input: { scope: Scope; confirm?: boolean }): Promise<Operation>;\n /** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; check it with operation(). */\n refresh(input?: { axes?: Axis[] }): Promise<Operation>;\n operation(operationId: string): Promise<Operation>;\n};`;\n\nexport function createSelfImproveNamespace(options: SelfImproveNamespaceOptions): PoCodemodeNamespace {\n const operations = new Map<string, SelfImproveOperation>();\n let next = 0;\n const remember = (operation: SelfImproveOperation): SelfImproveOperation => {\n operations.set(operation.operationId, operation);\n for (const id of operations.keys()) {\n if (operations.size <= MAX_OPERATIONS) break;\n if (operations.get(id)?.state !== 'queued') operations.delete(id);\n }\n return operation;\n };\n return {\n name: 'selfImprove',\n summary:\n \"Reload Po's own packages after editing them, or refresh this session's mode, domains and profile config, without restarting. Help mode, main agent only.\",\n declarations: DECLARATIONS,\n bind(run) {\n if (run.sessionId !== options.sessionId) throw new Error('The selfImprove namespace belongs to another session.');\n const check = () => {\n run.signal.throwIfAborted();\n options.assertActive();\n if (run.caller !== 'main') throw new Error('Only the main agent may reload or refresh Po.');\n };\n return {\n plugins: async () => {\n check();\n return { failures: JSON.parse(JSON.stringify(options.failures())) as unknown };\n },\n reload: async (input: unknown) => {\n check();\n const { scope, confirm } = (input ?? {}) as { scope?: unknown; confirm?: unknown };\n if (!SCOPES.includes(scope as SelfImproveScope))\n throw new Error(\"reload needs scope 'session', 'workspace' or 'global'.\");\n if (scope === 'global' && confirm !== true)\n throw new Error('A global reload changes every session; ask the person, then pass confirm: true.');\n const operationId = `reload-${String(++next)}`;\n const queued = remember({ operationId, scope: scope as SelfImproveScope, state: 'queued' });\n // Not awaited: a session reload waits for this tool round to end.\n void options.service.reload({ scope: queued.scope, sessionId: options.sessionId }).then(\n (result) =>\n remember({\n ...queued,\n state: result.failed.length === 0 ? 'applied' : 'partial',\n result: JSON.parse(JSON.stringify(result)) as SelfImproveOperation['result'],\n }),\n (error: unknown) =>\n remember({ ...queued, state: 'failed', error: error instanceof Error ? error.message : String(error) }),\n );\n return { ...queued };\n },\n refresh: async (input: unknown) => {\n check();\n const { axes = AXES } = (input ?? {}) as { axes?: unknown };\n if (\n !Array.isArray(axes) ||\n axes.length === 0 ||\n !axes.every((axis) => AXES.includes(axis as PoHeadlessRefreshAxis))\n )\n throw new Error(\"refresh axes are 'majorMode', 'domains' and 'profile'.\");\n const queued = remember({\n operationId: `refresh-${String(++next)}`,\n scope: 'session',\n axes: [...new Set(axes as PoHeadlessRefreshAxis[])],\n state: 'queued',\n });\n // Not awaited: the refresh waits for this tool round to end.\n void options.service.refresh({ sessionId: options.sessionId, axes: queued.axes! }).then(\n () => remember({ ...queued, state: 'applied' }),\n (error: unknown) =>\n remember({ ...queued, state: 'failed', error: error instanceof Error ? error.message : String(error) }),\n );\n return JSON.parse(JSON.stringify(queued)) as SelfImproveOperation;\n },\n operation: async (operationId: unknown) => {\n check();\n const operation = typeof operationId === 'string' ? operations.get(operationId) : undefined;\n if (operation === undefined) throw new Error(`No operation '${String(operationId)}'.`);\n return JSON.parse(JSON.stringify(operation)) as SelfImproveOperation;\n },\n };\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessCommand, PoHeadlessHostService, PoHeadlessResource } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN, type PoPackageFailureRecord, type PoSelfImprove } from '@agimon-ai/po-core/help';\nimport {\n type PoServerPluginContext,\n type PoServerSessionPlugin,\n packageResourcePath,\n readPackageResource,\n} from '@agimon-ai/po-core/serverPlugin';\nimport { defineMinorMode, serverMinorModes, type MinorModeOwner, type MinorModeState } from '@agimon-ai/po-minor-mode';\n\nimport {\n HELP_COMMAND_DESCRIPTION,\n HELP_COMMAND_NAME,\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_PACKAGE_SOURCE,\n HELP_CHATGPT_SKILL,\n HELP_CODEMODE_SKILL,\n HELP_NATIVE_SKILL,\n HELP_SELF_IMPROVE_SKILL,\n HELP_SKILL,\n} from '../../constants/help';\nimport { createHelpStatusTool, helpStatusDetail, serverHelpStatus } from '../helpStatus';\nimport { createSelfImproveNamespace } from '../selfImproveNamespace';\nexport function createHelpServerSession(\n host: PoHeadlessHostService,\n packageFailures: () => readonly PoPackageFailureRecord[] = () => [],\n /** The host's package reload; without it (edge, tests) Help offers no selfImprove namespace. */\n selfImprove?: PoSelfImprove,\n): PoServerSessionPlugin {\n let modeOwner: MinorModeOwner | undefined;\n let pending: boolean | undefined;\n let failure: string | undefined;\n let generation = 0;\n let disposed = false;\n const active = () => (host.context.selection.state?.['minor-mode'] ?? []).includes(HELP_MODE_ID);\n const inspect = () => serverHelpStatus(host.inspectCapabilities(), active(), packageFailures());\n const modeState = (): MinorModeState => {\n const report = inspect();\n return {\n activation: pending === true ? 'activating' : active() ? 'active' : 'inactive',\n condition:\n pending !== undefined || !report.ready\n ? 'queued'\n : failure\n ? 'failed'\n : report.activation === 'degraded'\n ? 'degraded'\n : 'ready',\n ...(pending !== undefined\n ? { detail: 'applying Help capabilities' }\n : failure\n ? { detail: failure }\n : active()\n ? { detail: helpStatusDetail(report) }\n : {}),\n actions: [\n {\n id: 'activate',\n enabled: !active() && pending === undefined,\n ...(!active() && pending === undefined ? {} : { disabledReason: 'Help is active or changing.' }),\n },\n {\n id: 'deactivate',\n enabled: active() || pending === true,\n ...(active() || pending === true ? {} : { disabledReason: 'Help mode is not active.' }),\n },\n ],\n };\n };\n const resources: PoHeadlessResource[] = [\n { when: HELP_WHEN, name: 'po-help', kind: 'context', read: () => HELP_GUIDANCE },\n {\n when: HELP_WHEN,\n ...HELP_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-help/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-help/SKILL.md');\n if (!text.trim()) throw new Error('The installed Help skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CHATGPT_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-chatgpt-instructions/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(\n import.meta.url,\n 'src/prompts/help-how-to-chatgpt-instructions/SKILL.md',\n );\n if (!text.trim()) throw new Error('The installed ChatGPT instruction skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_NATIVE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-native-extension/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-native-extension/SKILL.md');\n if (!text.trim()) throw new Error('The installed native extension skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CODEMODE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-codemode-plugin/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-codemode-plugin/SKILL.md');\n if (!text.trim()) throw new Error('The installed code-mode plugin skill is missing or unreadable.');\n return text;\n },\n },\n // Pinned like every code-mode guide, but listed only where the host can reload and Help is on.\n ...(selfImprove === undefined\n ? []\n : [\n {\n when: HELP_WHEN,\n ...HELP_SELF_IMPROVE_SKILL,\n kind: 'skill' as const,\n pinned: true,\n path: packageResourcePath(import.meta.url, 'src/prompts/codemode-how-to-self-improve/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/codemode-how-to-self-improve/SKILL.md'),\n },\n ]),\n ];\n const selectMode = async (enabled: boolean, signal?: AbortSignal): Promise<void> => {\n if (disposed) throw new Error('Help runtime is disposed.');\n signal?.throwIfAborted();\n const operation = ++generation;\n pending = enabled;\n failure = undefined;\n modeOwner?.publish();\n try {\n if (enabled) await resources[1]!.read(host.context);\n signal?.throwIfAborted();\n if (operation !== generation || disposed) throw new Error('Help activation was cancelled.');\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== HELP_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, HELP_MODE_ID] : modes,\n });\n } catch (error) {\n if (operation === generation) failure = (error instanceof Error ? error.message : String(error)).slice(0, 160);\n throw error;\n } finally {\n if (operation === generation) {\n pending = undefined;\n modeOwner?.publish();\n }\n }\n };\n const command: PoHeadlessCommand = {\n name: HELP_COMMAND_NAME,\n description: HELP_COMMAND_DESCRIPTION,\n async execute(_args, execution) {\n await selectMode(!(pending ?? active()));\n await execution.client.notify({\n title: 'Po Help',\n body: active() ? 'Help mode activated.' : 'Help mode deactivated.',\n level: 'info',\n });\n },\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: HELP_PACKAGE_SOURCE,\n id: HELP_MODE_ID,\n label: 'Help',\n description: 'Package guidance and read-only diagnostics for agent setup and debugging.',\n order: 50,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Expose Help guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Withdraw Help-only guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, _argumentsValue, { signal }) {\n if (actionId !== 'activate' && actionId !== 'deactivate')\n throw new Error(`Unknown Help mode action: ${actionId}`);\n await selectMode(actionId === 'activate', signal);\n return { message: active() ? 'Help mode activated.' : 'Help mode deactivated.' };\n },\n }).createOwner(undefined);\n const assertHelpActive = () => {\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n };\n // Registered only while Help is on: the activity starts with Help and stops when it is withdrawn.\n const selfImproveService = (cordis: PoServerPluginContext['context']) => {\n cordis.inject([PO_CODEMODE_SERVICE], (scoped) => {\n const codemode = readPoCodemode(scoped);\n if (!codemode || !selfImprove) return undefined;\n const namespace = createSelfImproveNamespace({\n sessionId: host.context.sessionId,\n service: selfImprove,\n failures: packageFailures,\n assertActive: assertHelpActive,\n });\n const activity = host.registerActivity({\n when: HELP_WHEN,\n name: 'selfImprove',\n start: () => {\n const registration = codemode.register(HELP_PACKAGE_SOURCE, namespace);\n return () => registration.dispose();\n },\n });\n return () => activity.dispose();\n });\n };\n return {\n services: [serverMinorModes([modeOwner]), ...(selfImprove ? [selfImproveService] : [])],\n resources,\n commands: [command],\n tools: [\n createHelpStatusTool(inspect, (signal) => {\n signal?.throwIfAborted();\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n return signal ?? new AbortController().signal;\n }),\n ],\n onDispose() {\n disposed = true;\n generation += 1;\n },\n };\n}\n","import { readPoPackageHealth, readPoSelfImprove } from '@agimon-ai/po-core/help';\nimport type { PoServerPluginDefinition, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createHelpServerSession } from '../../../../../services/helpServerSession';\n\nexport default (({ agent, context }): Partial<PoServerSessionPlugin> =>\n agent\n ? createHelpServerSession(agent, () => readPoPackageHealth(context)?.failures() ?? [], readPoSelfImprove(context))\n : {}) satisfies NonNullable<PoServerPluginDefinition['session']>;\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport runtime from './_lib/runtime.server';\n\nexport default defineRoot((context: PoServerPluginContext) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n activities: value.activities,\n onStart: value.onStart,\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.commands?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\n// Present only where the host binds package reload; see createHelpServerSession.\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[5],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[4],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[3],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[2],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[1],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.tools?.[0],\n { cardinality: 'optional' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandPoHelp from '../src/extensions/workspaces/sessions/(backend)/command/po-help.server';\nimport resourceCodemodeHowToSelfImprove from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server';\nimport resourcePoDevelopCodemodePlugin from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server';\nimport resourcePoDevelopNativeExtension from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server';\nimport resourcePoHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-help.server';\nimport resourcePoUseChatgptInstructions from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server';\nimport resourcePoUseHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server';\nimport toolHelpStatus from '../src/extensions/workspaces/sessions/(backend)/tool/help_status.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-help',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'po-help' }, at(commandPoHelp, contextSession))]); },\n get resources(): PoServerSessionPlugin['resources'] { return defined([at(resourceCodemodeHowToSelfImprove, contextSession), at(resourcePoDevelopCodemodePlugin, contextSession), at(resourcePoDevelopNativeExtension, contextSession), at(resourcePoHelp, contextSession), at(resourcePoUseChatgptInstructions, contextSession), at(resourcePoUseHelp, contextSession)]); },\n get tools(): PoServerSessionPlugin['tools'] { return defined([via({ name: 'help_status' }, at(toolHelpStatus, contextSession))]); },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;AAAA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACxC,MAAa,eAAe;AAC5B,MAAa,sBAAsB;AACnC,MAAa,aAAa;CACxB,MAAM;CACN,aACE;AACJ;AACA,MAAa,gBACX;AACF,MAAa,wBAAwB;AACrC,MAAa,+BACX;AAGF,MAAa,qBAAqB;CAChC,MAAM;CACN,aACE;AACJ;AAEA,MAAa,sBAAsB;CACjC,MAAM;CACN,aACE;AACJ;AAEA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aACE;AACJ;AAEA,MAAa,0BAA0B;CACrC,MAAM;CACN,aACE;AACJ;;;ACpCA,MAAa,uBAAuBA,QAAAA,KAAK,OAAO,CAA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1
+ {"version":3,"file":"server.cjs","names":["Type","defineTool","HELP_WHEN","HELP_WHEN","packageResourcePath","readPackageResource","defineMinorMode","PO_CODEMODE_SERVICE","readPoCodemode","serverMinorModes","readPoPackageHealth","readPoSelfImprove","defineRoot","runtime","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","composeRootHooks","commandPoHelp","resourceCodemodeHowToSelfImprove","resourcePoDevelopCodemodePlugin","resourcePoDevelopNativeExtension","resourcePoHelp","resourcePoUseChatgptInstructions","resourcePoUseHelp","toolHelpStatus"],"sources":["../../src/constants/help.ts","../../src/schemas/diagnostics.ts","../../src/services/helpStatus/index.ts","../../src/services/selfImproveNamespace/index.ts","../../src/services/helpServerSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/help_status.server.ts","../../generated/server.ts"],"sourcesContent":["export const HELP_COMMAND_NAME = 'po-help';\nexport const HELP_COMMAND_DESCRIPTION = 'Toggle Help guidance and read-only support diagnostics';\nexport const HELP_MODE_ID = 'help';\nexport const HELP_PACKAGE_SOURCE = '@agimon-ai/po-help';\nexport const HELP_SKILL = {\n name: 'help-how-to-help',\n description:\n 'Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.',\n} as const;\nexport const HELP_GUIDANCE =\n 'Help mode is active. Read help-how-to-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.';\nexport const HELP_STATUS_TOOL_NAME = 'help_status';\nexport const HELP_STATUS_TOOL_DESCRIPTION =\n 'Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.';\nexport const HELP_STATUS_LIMIT = 128;\n\nexport const HELP_CHATGPT_SKILL = {\n name: 'help-how-to-chatgpt-instructions',\n description:\n \"Print a paste-ready ChatGPT project instruction (at most 8,000 characters) that routes code-mode work through this session's MCP tools and condenses every AGENTS.md rule. Writes no files.\",\n} as const;\n\nexport const HELP_CODEMODE_SKILL = {\n name: 'help-how-to-codemode-plugin',\n description:\n 'Add code-mode support to a Po package: contribute a namespace to exec and discover, replace the direct tool it supersedes, and ship the skill that teaches agents to use it.',\n} as const;\n\nexport const HELP_NATIVE_SKILL = {\n name: 'help-how-to-native-extension',\n description:\n \"Add or change a Po package's phone UI (.native files, native templates) so it mirrors the cockpit, passes the native build, and is approved and verified before it ships.\",\n} as const;\n\nexport const HELP_SELF_IMPROVE_SKILL = {\n name: 'codemode-how-to-self-improve',\n description:\n \"Reload Po's own packages after you edit them, without restarting Po or reopening the session. Use in Help mode after changing a plugin's source or build, or after adding or removing a package.\",\n} as const;\n","import { Type } from 'typebox';\n\nexport const helpStatusParameters = Type.Object({}, { additionalProperties: false });\n","import type { PoHeadlessCapabilitySnapshot } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN, type PoPackageFailureRecord } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverPlugin';\n\nimport {\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_STATUS_LIMIT,\n HELP_STATUS_TOOL_DESCRIPTION,\n HELP_STATUS_TOOL_NAME,\n} from '../../constants/help';\nimport { helpStatusParameters } from '../../schemas/diagnostics';\nimport type { HelpStatusReport } from './type';\n\n/** `packageFailures`: the host's failed global and workspace packages; they never degrade Help itself. */\nexport function serverHelpStatus(\n snapshot: PoHeadlessCapabilitySnapshot,\n enabled: boolean,\n packageFailures: readonly PoPackageFailureRecord[] = [],\n): HelpStatusReport {\n const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.['minor-mode'] === HELP_MODE_ID);\n const skills = entries.filter((entry) => entry.kind === 'skill');\n const tools = entries.filter((entry) => entry.kind === 'tool');\n const diagnostics = entries\n .filter((entry) => enabled && entry.reason && entry.reason !== 'inactive')\n .map((entry) => ({ source: entry.source, code: `HELP_${entry.reason!.replaceAll('-', '_').toUpperCase()}` }));\n const ready = snapshot.ready;\n return {\n activation: !enabled ? 'inactive' : !ready ? 'activating' : diagnostics.length ? 'degraded' : 'active',\n ready,\n revision: snapshot.revision,\n counts: {\n skills: ready ? skills.filter((entry) => entry.active && entry.discoverable).length : null,\n tools: tools.filter((entry) => entry.active).length,\n },\n skills: skills.slice(0, HELP_STATUS_LIMIT).map(({ name, source, active, discoverable, reason }) => ({\n name,\n source,\n active: active && discoverable,\n ...(reason ? { reason } : {}),\n })),\n tools: tools\n .slice(0, HELP_STATUS_LIMIT)\n .map(({ name, source, active, reason }) => ({ name, source, active, ...(reason ? { reason } : {}) })),\n diagnostics: diagnostics.slice(0, HELP_STATUS_LIMIT),\n packages: enabled ? packageFailures.slice(-HELP_STATUS_LIMIT) : [],\n truncated:\n skills.length > HELP_STATUS_LIMIT ||\n tools.length > HELP_STATUS_LIMIT ||\n diagnostics.length > HELP_STATUS_LIMIT ||\n (enabled && packageFailures.length > HELP_STATUS_LIMIT),\n };\n}\n\nexport function helpStatusDetail(report: HelpStatusReport): string {\n return `${report.counts.skills ?? 'pending'} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? ' (diagnostics available)' : ''}`;\n}\n\nexport function createHelpStatusTool(\n inspect: () => HelpStatusReport | Promise<HelpStatusReport>,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: HELP_STATUS_TOOL_NAME,\n description: HELP_STATUS_TOOL_DESCRIPTION,\n parameters: helpStatusParameters,\n when: HELP_WHEN,\n promptGuidelines: [HELP_GUIDANCE],\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const report = await inspect();\n signal.throwIfAborted();\n authorize(execution.signal);\n return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }], details: report };\n },\n });\n}\n","import type { PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessRefreshAxis } from '@agimon-ai/po-core/headless';\n\nimport type { SelfImproveNamespaceOptions, SelfImproveOperation, SelfImproveScope } from './type';\n\n/** Finished operations kept for `operation(id)`; older ones are forgotten first. */\nconst MAX_OPERATIONS = 20;\nconst SCOPES: readonly SelfImproveScope[] = ['session', 'workspace', 'global'];\nconst AXES: readonly PoHeadlessRefreshAxis[] = ['majorMode', 'domains', 'profile'];\nconst OUTCOME_MESSAGE_TYPE = 'po-help/self-improve';\n\n/** One line the agent can pass on to the person without calling operation(). */\nfunction describeOutcome(operation: SelfImproveOperation): string {\n const what = operation.axes\n ? `Refresh ${operation.operationId} (${operation.axes.join(', ')})`\n : `Reload ${operation.operationId} (${operation.scope} scope)`;\n const tell = 'Tell the person the outcome.';\n if (operation.state === 'failed')\n return `${what} failed, nothing changed: ${(operation.error ?? 'unknown error').replace(/\\.$/u, '')}. ${tell}`;\n const result = operation.result;\n const parts = [\n result?.installed.length ? `installed ${result.installed.join(', ')}` : '',\n result?.removed.length ? `removed ${result.removed.join(', ')}` : '',\n result?.failed.length\n ? `failed ${result.failed.map((item) => `${item.packageName} (${item.reason})`).join(', ')}, which keep their previous build`\n : '',\n ].filter(Boolean);\n return `${what} ${operation.state}${parts.length ? `: ${parts.join('; ')}` : ''}. ${tell}`;\n}\n\nconst DECLARATIONS = `type Scope = 'session' | 'workspace' | 'global';\ntype Axis = 'majorMode' | 'domains' | 'profile';\ninterface PackageFailure { scope: string; packageName: string; stage: string; reason: string; previous?: 'restored' | 'lost' | 'none'; at: string }\ninterface Operation {\n operationId: string; scope: Scope; axes?: Axis[];\n /** partial: applied, but some packages failed and keep their previous build when they had one. */\n state: 'queued' | 'applied' | 'partial' | 'failed';\n result?: { installed: string[]; removed: string[]; failed: { packageName: string; reason: string }[] };\n error?: string;\n /** Why the outcome follow-up could not reach you, when it did not. */\n undelivered?: string;\n}\ndeclare const selfImprove: {\n /** Packages whose current build failed to load or install, by scope. */\n plugins(): Promise<{ failures: PackageFailure[] }>;\n /** Queues a reload of one scope's packages from disk. When it finishes you get a follow-up message with the outcome; operation() returns it too. global needs confirm: true, after the person agreed. */\n reload(input: { scope: Scope; confirm?: boolean }): Promise<Operation>;\n /** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; reports its outcome like reload. */\n refresh(input?: { axes?: Axis[] }): Promise<Operation>;\n operation(operationId: string): Promise<Operation>;\n};`;\n\nexport function createSelfImproveNamespace(options: SelfImproveNamespaceOptions): PoCodemodeNamespace {\n const operations = new Map<string, SelfImproveOperation>();\n let next = 0;\n const remember = (operation: SelfImproveOperation): SelfImproveOperation => {\n operations.set(operation.operationId, operation);\n for (const id of operations.keys()) {\n if (operations.size <= MAX_OPERATIONS) break;\n if (operations.get(id)?.state !== 'queued') operations.delete(id);\n }\n return operation;\n };\n // The agent hears the outcome on its own instead of being asked whether a queued reload worked.\n const finish = (operation: SelfImproveOperation) => {\n remember(operation);\n void Promise.resolve(\n options.admitMessage?.(\n { type: OUTCOME_MESSAGE_TYPE, text: describeOutcome(operation), display: true },\n 'followUp',\n ),\n ).catch((error: unknown) => {\n // A session closed mid-reload cannot take the message; operation(id) reports the outcome and why it was not sent.\n remember({ ...operation, undelivered: error instanceof Error ? error.message : String(error) });\n });\n };\n return {\n name: 'selfImprove',\n summary:\n \"Reload Po's own packages after editing them, or refresh this session's mode, domains and profile config, without restarting. Help mode, main agent only.\",\n declarations: DECLARATIONS,\n bind(run) {\n if (run.sessionId !== options.sessionId) throw new Error('The selfImprove namespace belongs to another session.');\n const check = () => {\n run.signal.throwIfAborted();\n options.assertActive();\n if (run.caller !== 'main') throw new Error('Only the main agent may reload or refresh Po.');\n };\n return {\n plugins: async () => {\n check();\n return { failures: JSON.parse(JSON.stringify(options.failures())) as unknown };\n },\n reload: async (input: unknown) => {\n check();\n const { scope, confirm } = (input ?? {}) as { scope?: unknown; confirm?: unknown };\n if (!SCOPES.includes(scope as SelfImproveScope))\n throw new Error(\"reload needs scope 'session', 'workspace' or 'global'.\");\n if (scope === 'global' && confirm !== true)\n throw new Error('A global reload changes every session; ask the person, then pass confirm: true.');\n const operationId = `reload-${String(++next)}`;\n const queued = remember({ operationId, scope: scope as SelfImproveScope, state: 'queued' });\n // Not awaited: a session reload waits for this tool round to end.\n void options.service.reload({ scope: queued.scope, sessionId: options.sessionId }).then(\n (result) =>\n finish({\n ...queued,\n state: result.failed.length === 0 ? 'applied' : 'partial',\n result: JSON.parse(JSON.stringify(result)) as SelfImproveOperation['result'],\n }),\n (error: unknown) =>\n finish({ ...queued, state: 'failed', error: error instanceof Error ? error.message : String(error) }),\n );\n return { ...queued };\n },\n refresh: async (input: unknown) => {\n check();\n const { axes = AXES } = (input ?? {}) as { axes?: unknown };\n if (\n !Array.isArray(axes) ||\n axes.length === 0 ||\n !axes.every((axis) => AXES.includes(axis as PoHeadlessRefreshAxis))\n )\n throw new Error(\"refresh axes are 'majorMode', 'domains' and 'profile'.\");\n const queued = remember({\n operationId: `refresh-${String(++next)}`,\n scope: 'session',\n axes: [...new Set(axes as PoHeadlessRefreshAxis[])],\n state: 'queued',\n });\n // Not awaited: the refresh waits for this tool round to end.\n void options.service.refresh({ sessionId: options.sessionId, axes: queued.axes! }).then(\n () => finish({ ...queued, state: 'applied' }),\n (error: unknown) =>\n finish({ ...queued, state: 'failed', error: error instanceof Error ? error.message : String(error) }),\n );\n return JSON.parse(JSON.stringify(queued)) as SelfImproveOperation;\n },\n operation: async (operationId: unknown) => {\n check();\n const operation = typeof operationId === 'string' ? operations.get(operationId) : undefined;\n if (operation === undefined) throw new Error(`No operation '${String(operationId)}'.`);\n return JSON.parse(JSON.stringify(operation)) as SelfImproveOperation;\n },\n };\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessCommand, PoHeadlessHostService, PoHeadlessResource } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN, type PoPackageFailureRecord, type PoSelfImprove } from '@agimon-ai/po-core/help';\nimport {\n type PoServerPluginContext,\n type PoServerSessionPlugin,\n packageResourcePath,\n readPackageResource,\n} from '@agimon-ai/po-core/serverPlugin';\nimport { defineMinorMode, serverMinorModes, type MinorModeOwner, type MinorModeState } from '@agimon-ai/po-minor-mode';\n\nimport {\n HELP_COMMAND_DESCRIPTION,\n HELP_COMMAND_NAME,\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_PACKAGE_SOURCE,\n HELP_CHATGPT_SKILL,\n HELP_CODEMODE_SKILL,\n HELP_NATIVE_SKILL,\n HELP_SELF_IMPROVE_SKILL,\n HELP_SKILL,\n} from '../../constants/help';\nimport { createHelpStatusTool, helpStatusDetail, serverHelpStatus } from '../helpStatus';\nimport { createSelfImproveNamespace } from '../selfImproveNamespace';\nexport function createHelpServerSession(\n host: PoHeadlessHostService,\n packageFailures: () => readonly PoPackageFailureRecord[] = () => [],\n /** The host's package reload; without it (edge, tests) Help offers no selfImprove namespace. */\n selfImprove?: PoSelfImprove,\n): PoServerSessionPlugin {\n let modeOwner: MinorModeOwner | undefined;\n let pending: boolean | undefined;\n let failure: string | undefined;\n let generation = 0;\n let disposed = false;\n const active = () => (host.context.selection.state?.['minor-mode'] ?? []).includes(HELP_MODE_ID);\n const inspect = () => serverHelpStatus(host.inspectCapabilities(), active(), packageFailures());\n const modeState = (): MinorModeState => {\n const report = inspect();\n return {\n activation: pending === true ? 'activating' : active() ? 'active' : 'inactive',\n condition:\n pending !== undefined || !report.ready\n ? 'queued'\n : failure\n ? 'failed'\n : report.activation === 'degraded'\n ? 'degraded'\n : 'ready',\n ...(pending !== undefined\n ? { detail: 'applying Help capabilities' }\n : failure\n ? { detail: failure }\n : active()\n ? { detail: helpStatusDetail(report) }\n : {}),\n actions: [\n {\n id: 'activate',\n enabled: !active() && pending === undefined,\n ...(!active() && pending === undefined ? {} : { disabledReason: 'Help is active or changing.' }),\n },\n {\n id: 'deactivate',\n enabled: active() || pending === true,\n ...(active() || pending === true ? {} : { disabledReason: 'Help mode is not active.' }),\n },\n ],\n };\n };\n const resources: PoHeadlessResource[] = [\n { when: HELP_WHEN, name: 'po-help', kind: 'context', read: () => HELP_GUIDANCE },\n {\n when: HELP_WHEN,\n ...HELP_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-help/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-help/SKILL.md');\n if (!text.trim()) throw new Error('The installed Help skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CHATGPT_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-chatgpt-instructions/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(\n import.meta.url,\n 'src/prompts/help-how-to-chatgpt-instructions/SKILL.md',\n );\n if (!text.trim()) throw new Error('The installed ChatGPT instruction skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_NATIVE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-native-extension/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-native-extension/SKILL.md');\n if (!text.trim()) throw new Error('The installed native extension skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CODEMODE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-codemode-plugin/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-codemode-plugin/SKILL.md');\n if (!text.trim()) throw new Error('The installed code-mode plugin skill is missing or unreadable.');\n return text;\n },\n },\n // Pinned like every code-mode guide, but listed only where the host can reload and Help is on.\n ...(selfImprove === undefined\n ? []\n : [\n {\n when: HELP_WHEN,\n ...HELP_SELF_IMPROVE_SKILL,\n kind: 'skill' as const,\n pinned: true,\n path: packageResourcePath(import.meta.url, 'src/prompts/codemode-how-to-self-improve/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/codemode-how-to-self-improve/SKILL.md'),\n },\n ]),\n ];\n const selectMode = async (enabled: boolean, signal?: AbortSignal): Promise<void> => {\n if (disposed) throw new Error('Help runtime is disposed.');\n signal?.throwIfAborted();\n const operation = ++generation;\n pending = enabled;\n failure = undefined;\n modeOwner?.publish();\n try {\n if (enabled) await resources[1]!.read(host.context);\n signal?.throwIfAborted();\n if (operation !== generation || disposed) throw new Error('Help activation was cancelled.');\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== HELP_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, HELP_MODE_ID] : modes,\n });\n } catch (error) {\n if (operation === generation) failure = (error instanceof Error ? error.message : String(error)).slice(0, 160);\n throw error;\n } finally {\n if (operation === generation) {\n pending = undefined;\n modeOwner?.publish();\n }\n }\n };\n const command: PoHeadlessCommand = {\n name: HELP_COMMAND_NAME,\n description: HELP_COMMAND_DESCRIPTION,\n async execute(_args, execution) {\n await selectMode(!(pending ?? active()));\n await execution.client.notify({\n title: 'Po Help',\n body: active() ? 'Help mode activated.' : 'Help mode deactivated.',\n level: 'info',\n });\n },\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: HELP_PACKAGE_SOURCE,\n id: HELP_MODE_ID,\n label: 'Help',\n description: 'Package guidance and read-only diagnostics for agent setup and debugging.',\n order: 50,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Expose Help guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Withdraw Help-only guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, _argumentsValue, { signal }) {\n if (actionId !== 'activate' && actionId !== 'deactivate')\n throw new Error(`Unknown Help mode action: ${actionId}`);\n await selectMode(actionId === 'activate', signal);\n return { message: active() ? 'Help mode activated.' : 'Help mode deactivated.' };\n },\n }).createOwner(undefined);\n const assertHelpActive = () => {\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n };\n // Registered only while Help is on: the activity starts with Help and stops when it is withdrawn.\n const selfImproveService = (cordis: PoServerPluginContext['context']) => {\n cordis.inject([PO_CODEMODE_SERVICE], (scoped) => {\n const codemode = readPoCodemode(scoped);\n if (!codemode || !selfImprove) return undefined;\n const namespace = createSelfImproveNamespace({\n sessionId: host.context.sessionId,\n service: selfImprove,\n failures: packageFailures,\n assertActive: assertHelpActive,\n admitMessage: host.context.session.admitMessage?.bind(host.context.session),\n });\n const activity = host.registerActivity({\n when: HELP_WHEN,\n name: 'selfImprove',\n start: () => {\n const registration = codemode.register(HELP_PACKAGE_SOURCE, namespace);\n return () => registration.dispose();\n },\n });\n return () => activity.dispose();\n });\n };\n return {\n services: [serverMinorModes([modeOwner]), ...(selfImprove ? [selfImproveService] : [])],\n resources,\n commands: [command],\n tools: [\n createHelpStatusTool(inspect, (signal) => {\n signal?.throwIfAborted();\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n return signal ?? new AbortController().signal;\n }),\n ],\n onDispose() {\n disposed = true;\n generation += 1;\n },\n };\n}\n","import { readPoPackageHealth, readPoSelfImprove } from '@agimon-ai/po-core/help';\nimport type { PoServerPluginDefinition, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createHelpServerSession } from '../../../../../services/helpServerSession';\n\nexport default (({ agent, context }): Partial<PoServerSessionPlugin> =>\n agent\n ? createHelpServerSession(agent, () => readPoPackageHealth(context)?.failures() ?? [], readPoSelfImprove(context))\n : {}) satisfies NonNullable<PoServerPluginDefinition['session']>;\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport runtime from './_lib/runtime.server';\n\nexport default defineRoot((context: PoServerPluginContext) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n activities: value.activities,\n onStart: value.onStart,\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.commands?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\n// Present only where the host binds package reload; see createHelpServerSession.\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[5],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[4],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[3],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[2],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[1],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.tools?.[0],\n { cardinality: 'optional' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandPoHelp from '../src/extensions/workspaces/sessions/(backend)/command/po-help.server';\nimport resourceCodemodeHowToSelfImprove from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server';\nimport resourcePoDevelopCodemodePlugin from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server';\nimport resourcePoDevelopNativeExtension from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server';\nimport resourcePoHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-help.server';\nimport resourcePoUseChatgptInstructions from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server';\nimport resourcePoUseHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server';\nimport toolHelpStatus from '../src/extensions/workspaces/sessions/(backend)/tool/help_status.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-help',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'po-help' }, at(commandPoHelp, contextSession))]); },\n get resources(): PoServerSessionPlugin['resources'] { return defined([at(resourceCodemodeHowToSelfImprove, contextSession), at(resourcePoDevelopCodemodePlugin, contextSession), at(resourcePoDevelopNativeExtension, contextSession), at(resourcePoHelp, contextSession), at(resourcePoUseChatgptInstructions, contextSession), at(resourcePoUseHelp, contextSession)]); },\n get tools(): PoServerSessionPlugin['tools'] { return defined([via({ name: 'help_status' }, at(toolHelpStatus, contextSession))]); },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;AAAA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACxC,MAAa,eAAe;AAC5B,MAAa,sBAAsB;AACnC,MAAa,aAAa;CACxB,MAAM;CACN,aACE;AACJ;AACA,MAAa,gBACX;AACF,MAAa,wBAAwB;AACrC,MAAa,+BACX;AAGF,MAAa,qBAAqB;CAChC,MAAM;CACN,aACE;AACJ;AAEA,MAAa,sBAAsB;CACjC,MAAM;CACN,aACE;AACJ;AAEA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aACE;AACJ;AAEA,MAAa,0BAA0B;CACrC,MAAM;CACN,aACE;AACJ;;;ACpCA,MAAa,uBAAuBA,QAAAA,KAAK,OAAO,CAAC,GAAG,EAAE,sBAAsB,MAAM,CAAC;;;;ACanF,SAAgB,iBACd,UACA,SACA,kBAAqD,CAAC,GACpC;CAClB,MAAM,UAAU,SAAS,aAAa,QAAQ,UAAU,MAAM,MAAM,QAAQ,kBAAkB,YAAY;CAC1G,MAAM,SAAS,QAAQ,QAAQ,UAAU,MAAM,SAAS,OAAO;CAC/D,MAAM,QAAQ,QAAQ,QAAQ,UAAU,MAAM,SAAS,MAAM;CAC7D,MAAM,cAAc,QACjB,QAAQ,UAAU,WAAW,MAAM,UAAU,MAAM,WAAW,UAAU,CAAC,CACzE,KAAK,WAAW;EAAE,QAAQ,MAAM;EAAQ,MAAM,QAAQ,MAAM,OAAQ,WAAW,KAAK,GAAG,CAAC,CAAC,YAAY;CAAI,EAAE;CAC9G,MAAM,QAAQ,SAAS;CACvB,OAAO;EACL,YAAY,CAAC,UAAU,aAAa,CAAC,QAAQ,eAAe,YAAY,SAAS,aAAa;EAC9F;EACA,UAAU,SAAS;EACnB,QAAQ;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AO,QAAQ;KAAC,GAAGC,6CAAkC,cAAc;KAAG,GAAGC,2CAAiC,cAAc;KAAG,GAAGC,4CAAkC,cAAc;KAAG,GAAGC,wBAAgB,cAAc;KAAG,GAAGC,4CAAkC,cAAc;KAAG,GAAGC,4BAAmB,cAAc;IAAC,CAAC;GAAG;GAC1W,IAAI,QAAwC;IAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,cAAc,GAAG,GAAGC,4BAAgB,cAAc,CAAC,CAAC,CAAC;GAAG;GAClI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
@@ -111,6 +111,20 @@ const AXES = [
111
111
  "domains",
112
112
  "profile"
113
113
  ];
114
+ const OUTCOME_MESSAGE_TYPE = "po-help/self-improve";
115
+ /** One line the agent can pass on to the person without calling operation(). */
116
+ function describeOutcome(operation) {
117
+ const what = operation.axes ? `Refresh ${operation.operationId} (${operation.axes.join(", ")})` : `Reload ${operation.operationId} (${operation.scope} scope)`;
118
+ const tell = "Tell the person the outcome.";
119
+ if (operation.state === "failed") return `${what} failed, nothing changed: ${(operation.error ?? "unknown error").replace(/\.$/u, "")}. ${tell}`;
120
+ const result = operation.result;
121
+ const parts = [
122
+ result?.installed.length ? `installed ${result.installed.join(", ")}` : "",
123
+ result?.removed.length ? `removed ${result.removed.join(", ")}` : "",
124
+ result?.failed.length ? `failed ${result.failed.map((item) => `${item.packageName} (${item.reason})`).join(", ")}, which keep their previous build` : ""
125
+ ].filter(Boolean);
126
+ return `${what} ${operation.state}${parts.length ? `: ${parts.join("; ")}` : ""}. ${tell}`;
127
+ }
114
128
  const DECLARATIONS = `type Scope = 'session' | 'workspace' | 'global';
115
129
  type Axis = 'majorMode' | 'domains' | 'profile';
116
130
  interface PackageFailure { scope: string; packageName: string; stage: string; reason: string; previous?: 'restored' | 'lost' | 'none'; at: string }
@@ -120,13 +134,15 @@ interface Operation {
120
134
  state: 'queued' | 'applied' | 'partial' | 'failed';
121
135
  result?: { installed: string[]; removed: string[]; failed: { packageName: string; reason: string }[] };
122
136
  error?: string;
137
+ /** Why the outcome follow-up could not reach you, when it did not. */
138
+ undelivered?: string;
123
139
  }
124
140
  declare const selfImprove: {
125
141
  /** Packages whose current build failed to load or install, by scope. */
126
142
  plugins(): Promise<{ failures: PackageFailure[] }>;
127
- /** Queues a reload of one scope's packages from disk; check it with operation() in a later exec. global needs confirm: true, after the person agreed. */
143
+ /** Queues a reload of one scope's packages from disk. When it finishes you get a follow-up message with the outcome; operation() returns it too. global needs confirm: true, after the person agreed. */
128
144
  reload(input: { scope: Scope; confirm?: boolean }): Promise<Operation>;
129
- /** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; check it with operation(). */
145
+ /** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; reports its outcome like reload. */
130
146
  refresh(input?: { axes?: Axis[] }): Promise<Operation>;
131
147
  operation(operationId: string): Promise<Operation>;
132
148
  };`;
@@ -141,6 +157,19 @@ function createSelfImproveNamespace(options) {
141
157
  }
142
158
  return operation;
143
159
  };
160
+ const finish = (operation) => {
161
+ remember(operation);
162
+ Promise.resolve(options.admitMessage?.({
163
+ type: OUTCOME_MESSAGE_TYPE,
164
+ text: describeOutcome(operation),
165
+ display: true
166
+ }, "followUp")).catch((error) => {
167
+ remember({
168
+ ...operation,
169
+ undelivered: error instanceof Error ? error.message : String(error)
170
+ });
171
+ });
172
+ };
144
173
  return {
145
174
  name: "selfImprove",
146
175
  summary: "Reload Po's own packages after editing them, or refresh this session's mode, domains and profile config, without restarting. Help mode, main agent only.",
@@ -171,11 +200,11 @@ function createSelfImproveNamespace(options) {
171
200
  options.service.reload({
172
201
  scope: queued.scope,
173
202
  sessionId: options.sessionId
174
- }).then((result) => remember({
203
+ }).then((result) => finish({
175
204
  ...queued,
176
205
  state: result.failed.length === 0 ? "applied" : "partial",
177
206
  result: JSON.parse(JSON.stringify(result))
178
- }), (error) => remember({
207
+ }), (error) => finish({
179
208
  ...queued,
180
209
  state: "failed",
181
210
  error: error instanceof Error ? error.message : String(error)
@@ -195,10 +224,10 @@ function createSelfImproveNamespace(options) {
195
224
  options.service.refresh({
196
225
  sessionId: options.sessionId,
197
226
  axes: queued.axes
198
- }).then(() => remember({
227
+ }).then(() => finish({
199
228
  ...queued,
200
229
  state: "applied"
201
- }), (error) => remember({
230
+ }), (error) => finish({
202
231
  ...queued,
203
232
  state: "failed",
204
233
  error: error instanceof Error ? error.message : String(error)
@@ -381,7 +410,8 @@ function createHelpServerSession(host, packageFailures = () => [], selfImprove)
381
410
  sessionId: host.context.sessionId,
382
411
  service: selfImprove,
383
412
  failures: packageFailures,
384
- assertActive: assertHelpActive
413
+ assertActive: assertHelpActive,
414
+ admitMessage: host.context.session.admitMessage?.bind(host.context.session)
385
415
  });
386
416
  const activity = host.registerActivity({
387
417
  when: PO_HELP_WHEN,
@@ -1 +1 @@
1
- {"version":3,"file":"server.mjs","names":["HELP_WHEN","HELP_WHEN","runtime","rootSession","commandPoHelp","resourceCodemodeHowToSelfImprove","resourcePoDevelopCodemodePlugin","resourcePoDevelopNativeExtension","resourcePoHelp","resourcePoUseChatgptInstructions","resourcePoUseHelp","toolHelpStatus"],"sources":["../../src/constants/help.ts","../../src/schemas/diagnostics.ts","../../src/services/helpStatus/index.ts","../../src/services/selfImproveNamespace/index.ts","../../src/services/helpServerSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/help_status.server.ts","../../generated/server.ts"],"sourcesContent":["export const HELP_COMMAND_NAME = 'po-help';\nexport const HELP_COMMAND_DESCRIPTION = 'Toggle Help guidance and read-only support diagnostics';\nexport const HELP_MODE_ID = 'help';\nexport const HELP_PACKAGE_SOURCE = '@agimon-ai/po-help';\nexport const HELP_SKILL = {\n name: 'help-how-to-help',\n description:\n 'Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.',\n} as const;\nexport const HELP_GUIDANCE =\n 'Help mode is active. Read help-how-to-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.';\nexport const HELP_STATUS_TOOL_NAME = 'help_status';\nexport const HELP_STATUS_TOOL_DESCRIPTION =\n 'Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.';\nexport const HELP_STATUS_LIMIT = 128;\n\nexport const HELP_CHATGPT_SKILL = {\n name: 'help-how-to-chatgpt-instructions',\n description:\n \"Print a paste-ready ChatGPT project instruction (at most 8,000 characters) that routes code-mode work through this session's MCP tools and condenses every AGENTS.md rule. Writes no files.\",\n} as const;\n\nexport const HELP_CODEMODE_SKILL = {\n name: 'help-how-to-codemode-plugin',\n description:\n 'Add code-mode support to a Po package: contribute a namespace to exec and discover, replace the direct tool it supersedes, and ship the skill that teaches agents to use it.',\n} as const;\n\nexport const HELP_NATIVE_SKILL = {\n name: 'help-how-to-native-extension',\n description:\n \"Add or change a Po package's phone UI (.native files, native templates) so it mirrors the cockpit, passes the native build, and is approved and verified before it ships.\",\n} as const;\n\nexport const HELP_SELF_IMPROVE_SKILL = {\n name: 'codemode-how-to-self-improve',\n description:\n \"Reload Po's own packages after you edit them, without restarting Po or reopening the session. Use in Help mode after changing a plugin's source or build, or after adding or removing a package.\",\n} as const;\n","import { Type } from 'typebox';\n\nexport const helpStatusParameters = Type.Object({}, { additionalProperties: false });\n","import type { PoHeadlessCapabilitySnapshot } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN, type PoPackageFailureRecord } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverPlugin';\n\nimport {\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_STATUS_LIMIT,\n HELP_STATUS_TOOL_DESCRIPTION,\n HELP_STATUS_TOOL_NAME,\n} from '../../constants/help';\nimport { helpStatusParameters } from '../../schemas/diagnostics';\nimport type { HelpStatusReport } from './type';\n\n/** `packageFailures`: the host's failed global and workspace packages; they never degrade Help itself. */\nexport function serverHelpStatus(\n snapshot: PoHeadlessCapabilitySnapshot,\n enabled: boolean,\n packageFailures: readonly PoPackageFailureRecord[] = [],\n): HelpStatusReport {\n const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.['minor-mode'] === HELP_MODE_ID);\n const skills = entries.filter((entry) => entry.kind === 'skill');\n const tools = entries.filter((entry) => entry.kind === 'tool');\n const diagnostics = entries\n .filter((entry) => enabled && entry.reason && entry.reason !== 'inactive')\n .map((entry) => ({ source: entry.source, code: `HELP_${entry.reason!.replaceAll('-', '_').toUpperCase()}` }));\n const ready = snapshot.ready;\n return {\n activation: !enabled ? 'inactive' : !ready ? 'activating' : diagnostics.length ? 'degraded' : 'active',\n ready,\n revision: snapshot.revision,\n counts: {\n skills: ready ? skills.filter((entry) => entry.active && entry.discoverable).length : null,\n tools: tools.filter((entry) => entry.active).length,\n },\n skills: skills.slice(0, HELP_STATUS_LIMIT).map(({ name, source, active, discoverable, reason }) => ({\n name,\n source,\n active: active && discoverable,\n ...(reason ? { reason } : {}),\n })),\n tools: tools\n .slice(0, HELP_STATUS_LIMIT)\n .map(({ name, source, active, reason }) => ({ name, source, active, ...(reason ? { reason } : {}) })),\n diagnostics: diagnostics.slice(0, HELP_STATUS_LIMIT),\n packages: enabled ? packageFailures.slice(-HELP_STATUS_LIMIT) : [],\n truncated:\n skills.length > HELP_STATUS_LIMIT ||\n tools.length > HELP_STATUS_LIMIT ||\n diagnostics.length > HELP_STATUS_LIMIT ||\n (enabled && packageFailures.length > HELP_STATUS_LIMIT),\n };\n}\n\nexport function helpStatusDetail(report: HelpStatusReport): string {\n return `${report.counts.skills ?? 'pending'} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? ' (diagnostics available)' : ''}`;\n}\n\nexport function createHelpStatusTool(\n inspect: () => HelpStatusReport | Promise<HelpStatusReport>,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: HELP_STATUS_TOOL_NAME,\n description: HELP_STATUS_TOOL_DESCRIPTION,\n parameters: helpStatusParameters,\n when: HELP_WHEN,\n promptGuidelines: [HELP_GUIDANCE],\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const report = await inspect();\n signal.throwIfAborted();\n authorize(execution.signal);\n return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }], details: report };\n },\n });\n}\n","import type { PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessRefreshAxis } from '@agimon-ai/po-core/headless';\n\nimport type { SelfImproveNamespaceOptions, SelfImproveOperation, SelfImproveScope } from './type';\n\n/** Finished operations kept for `operation(id)`; older ones are forgotten first. */\nconst MAX_OPERATIONS = 20;\nconst SCOPES: readonly SelfImproveScope[] = ['session', 'workspace', 'global'];\nconst AXES: readonly PoHeadlessRefreshAxis[] = ['majorMode', 'domains', 'profile'];\n\nconst DECLARATIONS = `type Scope = 'session' | 'workspace' | 'global';\ntype Axis = 'majorMode' | 'domains' | 'profile';\ninterface PackageFailure { scope: string; packageName: string; stage: string; reason: string; previous?: 'restored' | 'lost' | 'none'; at: string }\ninterface Operation {\n operationId: string; scope: Scope; axes?: Axis[];\n /** partial: applied, but some packages failed and keep their previous build when they had one. */\n state: 'queued' | 'applied' | 'partial' | 'failed';\n result?: { installed: string[]; removed: string[]; failed: { packageName: string; reason: string }[] };\n error?: string;\n}\ndeclare const selfImprove: {\n /** Packages whose current build failed to load or install, by scope. */\n plugins(): Promise<{ failures: PackageFailure[] }>;\n /** Queues a reload of one scope's packages from disk; check it with operation() in a later exec. global needs confirm: true, after the person agreed. */\n reload(input: { scope: Scope; confirm?: boolean }): Promise<Operation>;\n /** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; check it with operation(). */\n refresh(input?: { axes?: Axis[] }): Promise<Operation>;\n operation(operationId: string): Promise<Operation>;\n};`;\n\nexport function createSelfImproveNamespace(options: SelfImproveNamespaceOptions): PoCodemodeNamespace {\n const operations = new Map<string, SelfImproveOperation>();\n let next = 0;\n const remember = (operation: SelfImproveOperation): SelfImproveOperation => {\n operations.set(operation.operationId, operation);\n for (const id of operations.keys()) {\n if (operations.size <= MAX_OPERATIONS) break;\n if (operations.get(id)?.state !== 'queued') operations.delete(id);\n }\n return operation;\n };\n return {\n name: 'selfImprove',\n summary:\n \"Reload Po's own packages after editing them, or refresh this session's mode, domains and profile config, without restarting. Help mode, main agent only.\",\n declarations: DECLARATIONS,\n bind(run) {\n if (run.sessionId !== options.sessionId) throw new Error('The selfImprove namespace belongs to another session.');\n const check = () => {\n run.signal.throwIfAborted();\n options.assertActive();\n if (run.caller !== 'main') throw new Error('Only the main agent may reload or refresh Po.');\n };\n return {\n plugins: async () => {\n check();\n return { failures: JSON.parse(JSON.stringify(options.failures())) as unknown };\n },\n reload: async (input: unknown) => {\n check();\n const { scope, confirm } = (input ?? {}) as { scope?: unknown; confirm?: unknown };\n if (!SCOPES.includes(scope as SelfImproveScope))\n throw new Error(\"reload needs scope 'session', 'workspace' or 'global'.\");\n if (scope === 'global' && confirm !== true)\n throw new Error('A global reload changes every session; ask the person, then pass confirm: true.');\n const operationId = `reload-${String(++next)}`;\n const queued = remember({ operationId, scope: scope as SelfImproveScope, state: 'queued' });\n // Not awaited: a session reload waits for this tool round to end.\n void options.service.reload({ scope: queued.scope, sessionId: options.sessionId }).then(\n (result) =>\n remember({\n ...queued,\n state: result.failed.length === 0 ? 'applied' : 'partial',\n result: JSON.parse(JSON.stringify(result)) as SelfImproveOperation['result'],\n }),\n (error: unknown) =>\n remember({ ...queued, state: 'failed', error: error instanceof Error ? error.message : String(error) }),\n );\n return { ...queued };\n },\n refresh: async (input: unknown) => {\n check();\n const { axes = AXES } = (input ?? {}) as { axes?: unknown };\n if (\n !Array.isArray(axes) ||\n axes.length === 0 ||\n !axes.every((axis) => AXES.includes(axis as PoHeadlessRefreshAxis))\n )\n throw new Error(\"refresh axes are 'majorMode', 'domains' and 'profile'.\");\n const queued = remember({\n operationId: `refresh-${String(++next)}`,\n scope: 'session',\n axes: [...new Set(axes as PoHeadlessRefreshAxis[])],\n state: 'queued',\n });\n // Not awaited: the refresh waits for this tool round to end.\n void options.service.refresh({ sessionId: options.sessionId, axes: queued.axes! }).then(\n () => remember({ ...queued, state: 'applied' }),\n (error: unknown) =>\n remember({ ...queued, state: 'failed', error: error instanceof Error ? error.message : String(error) }),\n );\n return JSON.parse(JSON.stringify(queued)) as SelfImproveOperation;\n },\n operation: async (operationId: unknown) => {\n check();\n const operation = typeof operationId === 'string' ? operations.get(operationId) : undefined;\n if (operation === undefined) throw new Error(`No operation '${String(operationId)}'.`);\n return JSON.parse(JSON.stringify(operation)) as SelfImproveOperation;\n },\n };\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessCommand, PoHeadlessHostService, PoHeadlessResource } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN, type PoPackageFailureRecord, type PoSelfImprove } from '@agimon-ai/po-core/help';\nimport {\n type PoServerPluginContext,\n type PoServerSessionPlugin,\n packageResourcePath,\n readPackageResource,\n} from '@agimon-ai/po-core/serverPlugin';\nimport { defineMinorMode, serverMinorModes, type MinorModeOwner, type MinorModeState } from '@agimon-ai/po-minor-mode';\n\nimport {\n HELP_COMMAND_DESCRIPTION,\n HELP_COMMAND_NAME,\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_PACKAGE_SOURCE,\n HELP_CHATGPT_SKILL,\n HELP_CODEMODE_SKILL,\n HELP_NATIVE_SKILL,\n HELP_SELF_IMPROVE_SKILL,\n HELP_SKILL,\n} from '../../constants/help';\nimport { createHelpStatusTool, helpStatusDetail, serverHelpStatus } from '../helpStatus';\nimport { createSelfImproveNamespace } from '../selfImproveNamespace';\nexport function createHelpServerSession(\n host: PoHeadlessHostService,\n packageFailures: () => readonly PoPackageFailureRecord[] = () => [],\n /** The host's package reload; without it (edge, tests) Help offers no selfImprove namespace. */\n selfImprove?: PoSelfImprove,\n): PoServerSessionPlugin {\n let modeOwner: MinorModeOwner | undefined;\n let pending: boolean | undefined;\n let failure: string | undefined;\n let generation = 0;\n let disposed = false;\n const active = () => (host.context.selection.state?.['minor-mode'] ?? []).includes(HELP_MODE_ID);\n const inspect = () => serverHelpStatus(host.inspectCapabilities(), active(), packageFailures());\n const modeState = (): MinorModeState => {\n const report = inspect();\n return {\n activation: pending === true ? 'activating' : active() ? 'active' : 'inactive',\n condition:\n pending !== undefined || !report.ready\n ? 'queued'\n : failure\n ? 'failed'\n : report.activation === 'degraded'\n ? 'degraded'\n : 'ready',\n ...(pending !== undefined\n ? { detail: 'applying Help capabilities' }\n : failure\n ? { detail: failure }\n : active()\n ? { detail: helpStatusDetail(report) }\n : {}),\n actions: [\n {\n id: 'activate',\n enabled: !active() && pending === undefined,\n ...(!active() && pending === undefined ? {} : { disabledReason: 'Help is active or changing.' }),\n },\n {\n id: 'deactivate',\n enabled: active() || pending === true,\n ...(active() || pending === true ? {} : { disabledReason: 'Help mode is not active.' }),\n },\n ],\n };\n };\n const resources: PoHeadlessResource[] = [\n { when: HELP_WHEN, name: 'po-help', kind: 'context', read: () => HELP_GUIDANCE },\n {\n when: HELP_WHEN,\n ...HELP_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-help/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-help/SKILL.md');\n if (!text.trim()) throw new Error('The installed Help skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CHATGPT_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-chatgpt-instructions/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(\n import.meta.url,\n 'src/prompts/help-how-to-chatgpt-instructions/SKILL.md',\n );\n if (!text.trim()) throw new Error('The installed ChatGPT instruction skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_NATIVE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-native-extension/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-native-extension/SKILL.md');\n if (!text.trim()) throw new Error('The installed native extension skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CODEMODE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-codemode-plugin/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-codemode-plugin/SKILL.md');\n if (!text.trim()) throw new Error('The installed code-mode plugin skill is missing or unreadable.');\n return text;\n },\n },\n // Pinned like every code-mode guide, but listed only where the host can reload and Help is on.\n ...(selfImprove === undefined\n ? []\n : [\n {\n when: HELP_WHEN,\n ...HELP_SELF_IMPROVE_SKILL,\n kind: 'skill' as const,\n pinned: true,\n path: packageResourcePath(import.meta.url, 'src/prompts/codemode-how-to-self-improve/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/codemode-how-to-self-improve/SKILL.md'),\n },\n ]),\n ];\n const selectMode = async (enabled: boolean, signal?: AbortSignal): Promise<void> => {\n if (disposed) throw new Error('Help runtime is disposed.');\n signal?.throwIfAborted();\n const operation = ++generation;\n pending = enabled;\n failure = undefined;\n modeOwner?.publish();\n try {\n if (enabled) await resources[1]!.read(host.context);\n signal?.throwIfAborted();\n if (operation !== generation || disposed) throw new Error('Help activation was cancelled.');\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== HELP_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, HELP_MODE_ID] : modes,\n });\n } catch (error) {\n if (operation === generation) failure = (error instanceof Error ? error.message : String(error)).slice(0, 160);\n throw error;\n } finally {\n if (operation === generation) {\n pending = undefined;\n modeOwner?.publish();\n }\n }\n };\n const command: PoHeadlessCommand = {\n name: HELP_COMMAND_NAME,\n description: HELP_COMMAND_DESCRIPTION,\n async execute(_args, execution) {\n await selectMode(!(pending ?? active()));\n await execution.client.notify({\n title: 'Po Help',\n body: active() ? 'Help mode activated.' : 'Help mode deactivated.',\n level: 'info',\n });\n },\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: HELP_PACKAGE_SOURCE,\n id: HELP_MODE_ID,\n label: 'Help',\n description: 'Package guidance and read-only diagnostics for agent setup and debugging.',\n order: 50,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Expose Help guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Withdraw Help-only guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, _argumentsValue, { signal }) {\n if (actionId !== 'activate' && actionId !== 'deactivate')\n throw new Error(`Unknown Help mode action: ${actionId}`);\n await selectMode(actionId === 'activate', signal);\n return { message: active() ? 'Help mode activated.' : 'Help mode deactivated.' };\n },\n }).createOwner(undefined);\n const assertHelpActive = () => {\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n };\n // Registered only while Help is on: the activity starts with Help and stops when it is withdrawn.\n const selfImproveService = (cordis: PoServerPluginContext['context']) => {\n cordis.inject([PO_CODEMODE_SERVICE], (scoped) => {\n const codemode = readPoCodemode(scoped);\n if (!codemode || !selfImprove) return undefined;\n const namespace = createSelfImproveNamespace({\n sessionId: host.context.sessionId,\n service: selfImprove,\n failures: packageFailures,\n assertActive: assertHelpActive,\n });\n const activity = host.registerActivity({\n when: HELP_WHEN,\n name: 'selfImprove',\n start: () => {\n const registration = codemode.register(HELP_PACKAGE_SOURCE, namespace);\n return () => registration.dispose();\n },\n });\n return () => activity.dispose();\n });\n };\n return {\n services: [serverMinorModes([modeOwner]), ...(selfImprove ? [selfImproveService] : [])],\n resources,\n commands: [command],\n tools: [\n createHelpStatusTool(inspect, (signal) => {\n signal?.throwIfAborted();\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n return signal ?? new AbortController().signal;\n }),\n ],\n onDispose() {\n disposed = true;\n generation += 1;\n },\n };\n}\n","import { readPoPackageHealth, readPoSelfImprove } from '@agimon-ai/po-core/help';\nimport type { PoServerPluginDefinition, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createHelpServerSession } from '../../../../../services/helpServerSession';\n\nexport default (({ agent, context }): Partial<PoServerSessionPlugin> =>\n agent\n ? createHelpServerSession(agent, () => readPoPackageHealth(context)?.failures() ?? [], readPoSelfImprove(context))\n : {}) satisfies NonNullable<PoServerPluginDefinition['session']>;\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport runtime from './_lib/runtime.server';\n\nexport default defineRoot((context: PoServerPluginContext) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n activities: value.activities,\n onStart: value.onStart,\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.commands?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\n// Present only where the host binds package reload; see createHelpServerSession.\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[5],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[4],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[3],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[2],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[1],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.tools?.[0],\n { cardinality: 'optional' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandPoHelp from '../src/extensions/workspaces/sessions/(backend)/command/po-help.server';\nimport resourceCodemodeHowToSelfImprove from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server';\nimport resourcePoDevelopCodemodePlugin from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server';\nimport resourcePoDevelopNativeExtension from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server';\nimport resourcePoHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-help.server';\nimport resourcePoUseChatgptInstructions from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server';\nimport resourcePoUseHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server';\nimport toolHelpStatus from '../src/extensions/workspaces/sessions/(backend)/tool/help_status.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-help',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'po-help' }, at(commandPoHelp, contextSession))]); },\n get resources(): PoServerSessionPlugin['resources'] { return defined([at(resourceCodemodeHowToSelfImprove, contextSession), at(resourcePoDevelopCodemodePlugin, contextSession), at(resourcePoDevelopNativeExtension, contextSession), at(resourcePoHelp, contextSession), at(resourcePoUseChatgptInstructions, contextSession), at(resourcePoUseHelp, contextSession)]); },\n get tools(): PoServerSessionPlugin['tools'] { return defined([via({ name: 'help_status' }, at(toolHelpStatus, contextSession))]); },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;AAAA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACxC,MAAa,eAAe;AAC5B,MAAa,sBAAsB;AACnC,MAAa,aAAa;CACxB,MAAM;CACN,aACE;AACJ;AACA,MAAa,gBACX;AACF,MAAa,wBAAwB;AACrC,MAAa,+BACX;AAGF,MAAa,qBAAqB;CAChC,MAAM;CACN,aACE;AACJ;AAEA,MAAa,sBAAsB;CACjC,MAAM;CACN,aACE;AACJ;AAEA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aACE;AACJ;AAEA,MAAa,0BAA0B;CACrC,MAAM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vG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.mjs","names":["HELP_WHEN","HELP_WHEN","runtime","rootSession","commandPoHelp","resourceCodemodeHowToSelfImprove","resourcePoDevelopCodemodePlugin","resourcePoDevelopNativeExtension","resourcePoHelp","resourcePoUseChatgptInstructions","resourcePoUseHelp","toolHelpStatus"],"sources":["../../src/constants/help.ts","../../src/schemas/diagnostics.ts","../../src/services/helpStatus/index.ts","../../src/services/selfImproveNamespace/index.ts","../../src/services/helpServerSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/help_status.server.ts","../../generated/server.ts"],"sourcesContent":["export const HELP_COMMAND_NAME = 'po-help';\nexport const HELP_COMMAND_DESCRIPTION = 'Toggle Help guidance and read-only support diagnostics';\nexport const HELP_MODE_ID = 'help';\nexport const HELP_PACKAGE_SOURCE = '@agimon-ai/po-help';\nexport const HELP_SKILL = {\n name: 'help-how-to-help',\n description:\n 'Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.',\n} as const;\nexport const HELP_GUIDANCE =\n 'Help mode is active. Read help-how-to-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.';\nexport const HELP_STATUS_TOOL_NAME = 'help_status';\nexport const HELP_STATUS_TOOL_DESCRIPTION =\n 'Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.';\nexport const HELP_STATUS_LIMIT = 128;\n\nexport const HELP_CHATGPT_SKILL = {\n name: 'help-how-to-chatgpt-instructions',\n description:\n \"Print a paste-ready ChatGPT project instruction (at most 8,000 characters) that routes code-mode work through this session's MCP tools and condenses every AGENTS.md rule. Writes no files.\",\n} as const;\n\nexport const HELP_CODEMODE_SKILL = {\n name: 'help-how-to-codemode-plugin',\n description:\n 'Add code-mode support to a Po package: contribute a namespace to exec and discover, replace the direct tool it supersedes, and ship the skill that teaches agents to use it.',\n} as const;\n\nexport const HELP_NATIVE_SKILL = {\n name: 'help-how-to-native-extension',\n description:\n \"Add or change a Po package's phone UI (.native files, native templates) so it mirrors the cockpit, passes the native build, and is approved and verified before it ships.\",\n} as const;\n\nexport const HELP_SELF_IMPROVE_SKILL = {\n name: 'codemode-how-to-self-improve',\n description:\n \"Reload Po's own packages after you edit them, without restarting Po or reopening the session. Use in Help mode after changing a plugin's source or build, or after adding or removing a package.\",\n} as const;\n","import { Type } from 'typebox';\n\nexport const helpStatusParameters = Type.Object({}, { additionalProperties: false });\n","import type { PoHeadlessCapabilitySnapshot } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN, type PoPackageFailureRecord } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverPlugin';\n\nimport {\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_STATUS_LIMIT,\n HELP_STATUS_TOOL_DESCRIPTION,\n HELP_STATUS_TOOL_NAME,\n} from '../../constants/help';\nimport { helpStatusParameters } from '../../schemas/diagnostics';\nimport type { HelpStatusReport } from './type';\n\n/** `packageFailures`: the host's failed global and workspace packages; they never degrade Help itself. */\nexport function serverHelpStatus(\n snapshot: PoHeadlessCapabilitySnapshot,\n enabled: boolean,\n packageFailures: readonly PoPackageFailureRecord[] = [],\n): HelpStatusReport {\n const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.['minor-mode'] === HELP_MODE_ID);\n const skills = entries.filter((entry) => entry.kind === 'skill');\n const tools = entries.filter((entry) => entry.kind === 'tool');\n const diagnostics = entries\n .filter((entry) => enabled && entry.reason && entry.reason !== 'inactive')\n .map((entry) => ({ source: entry.source, code: `HELP_${entry.reason!.replaceAll('-', '_').toUpperCase()}` }));\n const ready = snapshot.ready;\n return {\n activation: !enabled ? 'inactive' : !ready ? 'activating' : diagnostics.length ? 'degraded' : 'active',\n ready,\n revision: snapshot.revision,\n counts: {\n skills: ready ? skills.filter((entry) => entry.active && entry.discoverable).length : null,\n tools: tools.filter((entry) => entry.active).length,\n },\n skills: skills.slice(0, HELP_STATUS_LIMIT).map(({ name, source, active, discoverable, reason }) => ({\n name,\n source,\n active: active && discoverable,\n ...(reason ? { reason } : {}),\n })),\n tools: tools\n .slice(0, HELP_STATUS_LIMIT)\n .map(({ name, source, active, reason }) => ({ name, source, active, ...(reason ? { reason } : {}) })),\n diagnostics: diagnostics.slice(0, HELP_STATUS_LIMIT),\n packages: enabled ? packageFailures.slice(-HELP_STATUS_LIMIT) : [],\n truncated:\n skills.length > HELP_STATUS_LIMIT ||\n tools.length > HELP_STATUS_LIMIT ||\n diagnostics.length > HELP_STATUS_LIMIT ||\n (enabled && packageFailures.length > HELP_STATUS_LIMIT),\n };\n}\n\nexport function helpStatusDetail(report: HelpStatusReport): string {\n return `${report.counts.skills ?? 'pending'} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? ' (diagnostics available)' : ''}`;\n}\n\nexport function createHelpStatusTool(\n inspect: () => HelpStatusReport | Promise<HelpStatusReport>,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: HELP_STATUS_TOOL_NAME,\n description: HELP_STATUS_TOOL_DESCRIPTION,\n parameters: helpStatusParameters,\n when: HELP_WHEN,\n promptGuidelines: [HELP_GUIDANCE],\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const report = await inspect();\n signal.throwIfAborted();\n authorize(execution.signal);\n return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }], details: report };\n },\n });\n}\n","import type { PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessRefreshAxis } from '@agimon-ai/po-core/headless';\n\nimport type { SelfImproveNamespaceOptions, SelfImproveOperation, SelfImproveScope } from './type';\n\n/** Finished operations kept for `operation(id)`; older ones are forgotten first. */\nconst MAX_OPERATIONS = 20;\nconst SCOPES: readonly SelfImproveScope[] = ['session', 'workspace', 'global'];\nconst AXES: readonly PoHeadlessRefreshAxis[] = ['majorMode', 'domains', 'profile'];\nconst OUTCOME_MESSAGE_TYPE = 'po-help/self-improve';\n\n/** One line the agent can pass on to the person without calling operation(). */\nfunction describeOutcome(operation: SelfImproveOperation): string {\n const what = operation.axes\n ? `Refresh ${operation.operationId} (${operation.axes.join(', ')})`\n : `Reload ${operation.operationId} (${operation.scope} scope)`;\n const tell = 'Tell the person the outcome.';\n if (operation.state === 'failed')\n return `${what} failed, nothing changed: ${(operation.error ?? 'unknown error').replace(/\\.$/u, '')}. ${tell}`;\n const result = operation.result;\n const parts = [\n result?.installed.length ? `installed ${result.installed.join(', ')}` : '',\n result?.removed.length ? `removed ${result.removed.join(', ')}` : '',\n result?.failed.length\n ? `failed ${result.failed.map((item) => `${item.packageName} (${item.reason})`).join(', ')}, which keep their previous build`\n : '',\n ].filter(Boolean);\n return `${what} ${operation.state}${parts.length ? `: ${parts.join('; ')}` : ''}. ${tell}`;\n}\n\nconst DECLARATIONS = `type Scope = 'session' | 'workspace' | 'global';\ntype Axis = 'majorMode' | 'domains' | 'profile';\ninterface PackageFailure { scope: string; packageName: string; stage: string; reason: string; previous?: 'restored' | 'lost' | 'none'; at: string }\ninterface Operation {\n operationId: string; scope: Scope; axes?: Axis[];\n /** partial: applied, but some packages failed and keep their previous build when they had one. */\n state: 'queued' | 'applied' | 'partial' | 'failed';\n result?: { installed: string[]; removed: string[]; failed: { packageName: string; reason: string }[] };\n error?: string;\n /** Why the outcome follow-up could not reach you, when it did not. */\n undelivered?: string;\n}\ndeclare const selfImprove: {\n /** Packages whose current build failed to load or install, by scope. */\n plugins(): Promise<{ failures: PackageFailure[] }>;\n /** Queues a reload of one scope's packages from disk. When it finishes you get a follow-up message with the outcome; operation() returns it too. global needs confirm: true, after the person agreed. */\n reload(input: { scope: Scope; confirm?: boolean }): Promise<Operation>;\n /** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; reports its outcome like reload. */\n refresh(input?: { axes?: Axis[] }): Promise<Operation>;\n operation(operationId: string): Promise<Operation>;\n};`;\n\nexport function createSelfImproveNamespace(options: SelfImproveNamespaceOptions): PoCodemodeNamespace {\n const operations = new Map<string, SelfImproveOperation>();\n let next = 0;\n const remember = (operation: SelfImproveOperation): SelfImproveOperation => {\n operations.set(operation.operationId, operation);\n for (const id of operations.keys()) {\n if (operations.size <= MAX_OPERATIONS) break;\n if (operations.get(id)?.state !== 'queued') operations.delete(id);\n }\n return operation;\n };\n // The agent hears the outcome on its own instead of being asked whether a queued reload worked.\n const finish = (operation: SelfImproveOperation) => {\n remember(operation);\n void Promise.resolve(\n options.admitMessage?.(\n { type: OUTCOME_MESSAGE_TYPE, text: describeOutcome(operation), display: true },\n 'followUp',\n ),\n ).catch((error: unknown) => {\n // A session closed mid-reload cannot take the message; operation(id) reports the outcome and why it was not sent.\n remember({ ...operation, undelivered: error instanceof Error ? error.message : String(error) });\n });\n };\n return {\n name: 'selfImprove',\n summary:\n \"Reload Po's own packages after editing them, or refresh this session's mode, domains and profile config, without restarting. Help mode, main agent only.\",\n declarations: DECLARATIONS,\n bind(run) {\n if (run.sessionId !== options.sessionId) throw new Error('The selfImprove namespace belongs to another session.');\n const check = () => {\n run.signal.throwIfAborted();\n options.assertActive();\n if (run.caller !== 'main') throw new Error('Only the main agent may reload or refresh Po.');\n };\n return {\n plugins: async () => {\n check();\n return { failures: JSON.parse(JSON.stringify(options.failures())) as unknown };\n },\n reload: async (input: unknown) => {\n check();\n const { scope, confirm } = (input ?? {}) as { scope?: unknown; confirm?: unknown };\n if (!SCOPES.includes(scope as SelfImproveScope))\n throw new Error(\"reload needs scope 'session', 'workspace' or 'global'.\");\n if (scope === 'global' && confirm !== true)\n throw new Error('A global reload changes every session; ask the person, then pass confirm: true.');\n const operationId = `reload-${String(++next)}`;\n const queued = remember({ operationId, scope: scope as SelfImproveScope, state: 'queued' });\n // Not awaited: a session reload waits for this tool round to end.\n void options.service.reload({ scope: queued.scope, sessionId: options.sessionId }).then(\n (result) =>\n finish({\n ...queued,\n state: result.failed.length === 0 ? 'applied' : 'partial',\n result: JSON.parse(JSON.stringify(result)) as SelfImproveOperation['result'],\n }),\n (error: unknown) =>\n finish({ ...queued, state: 'failed', error: error instanceof Error ? error.message : String(error) }),\n );\n return { ...queued };\n },\n refresh: async (input: unknown) => {\n check();\n const { axes = AXES } = (input ?? {}) as { axes?: unknown };\n if (\n !Array.isArray(axes) ||\n axes.length === 0 ||\n !axes.every((axis) => AXES.includes(axis as PoHeadlessRefreshAxis))\n )\n throw new Error(\"refresh axes are 'majorMode', 'domains' and 'profile'.\");\n const queued = remember({\n operationId: `refresh-${String(++next)}`,\n scope: 'session',\n axes: [...new Set(axes as PoHeadlessRefreshAxis[])],\n state: 'queued',\n });\n // Not awaited: the refresh waits for this tool round to end.\n void options.service.refresh({ sessionId: options.sessionId, axes: queued.axes! }).then(\n () => finish({ ...queued, state: 'applied' }),\n (error: unknown) =>\n finish({ ...queued, state: 'failed', error: error instanceof Error ? error.message : String(error) }),\n );\n return JSON.parse(JSON.stringify(queued)) as SelfImproveOperation;\n },\n operation: async (operationId: unknown) => {\n check();\n const operation = typeof operationId === 'string' ? operations.get(operationId) : undefined;\n if (operation === undefined) throw new Error(`No operation '${String(operationId)}'.`);\n return JSON.parse(JSON.stringify(operation)) as SelfImproveOperation;\n },\n };\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode } from '@agimon-ai/po-core/codemode';\nimport type { PoHeadlessCommand, PoHeadlessHostService, PoHeadlessResource } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN, type PoPackageFailureRecord, type PoSelfImprove } from '@agimon-ai/po-core/help';\nimport {\n type PoServerPluginContext,\n type PoServerSessionPlugin,\n packageResourcePath,\n readPackageResource,\n} from '@agimon-ai/po-core/serverPlugin';\nimport { defineMinorMode, serverMinorModes, type MinorModeOwner, type MinorModeState } from '@agimon-ai/po-minor-mode';\n\nimport {\n HELP_COMMAND_DESCRIPTION,\n HELP_COMMAND_NAME,\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_PACKAGE_SOURCE,\n HELP_CHATGPT_SKILL,\n HELP_CODEMODE_SKILL,\n HELP_NATIVE_SKILL,\n HELP_SELF_IMPROVE_SKILL,\n HELP_SKILL,\n} from '../../constants/help';\nimport { createHelpStatusTool, helpStatusDetail, serverHelpStatus } from '../helpStatus';\nimport { createSelfImproveNamespace } from '../selfImproveNamespace';\nexport function createHelpServerSession(\n host: PoHeadlessHostService,\n packageFailures: () => readonly PoPackageFailureRecord[] = () => [],\n /** The host's package reload; without it (edge, tests) Help offers no selfImprove namespace. */\n selfImprove?: PoSelfImprove,\n): PoServerSessionPlugin {\n let modeOwner: MinorModeOwner | undefined;\n let pending: boolean | undefined;\n let failure: string | undefined;\n let generation = 0;\n let disposed = false;\n const active = () => (host.context.selection.state?.['minor-mode'] ?? []).includes(HELP_MODE_ID);\n const inspect = () => serverHelpStatus(host.inspectCapabilities(), active(), packageFailures());\n const modeState = (): MinorModeState => {\n const report = inspect();\n return {\n activation: pending === true ? 'activating' : active() ? 'active' : 'inactive',\n condition:\n pending !== undefined || !report.ready\n ? 'queued'\n : failure\n ? 'failed'\n : report.activation === 'degraded'\n ? 'degraded'\n : 'ready',\n ...(pending !== undefined\n ? { detail: 'applying Help capabilities' }\n : failure\n ? { detail: failure }\n : active()\n ? { detail: helpStatusDetail(report) }\n : {}),\n actions: [\n {\n id: 'activate',\n enabled: !active() && pending === undefined,\n ...(!active() && pending === undefined ? {} : { disabledReason: 'Help is active or changing.' }),\n },\n {\n id: 'deactivate',\n enabled: active() || pending === true,\n ...(active() || pending === true ? {} : { disabledReason: 'Help mode is not active.' }),\n },\n ],\n };\n };\n const resources: PoHeadlessResource[] = [\n { when: HELP_WHEN, name: 'po-help', kind: 'context', read: () => HELP_GUIDANCE },\n {\n when: HELP_WHEN,\n ...HELP_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-help/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-help/SKILL.md');\n if (!text.trim()) throw new Error('The installed Help skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CHATGPT_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-chatgpt-instructions/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(\n import.meta.url,\n 'src/prompts/help-how-to-chatgpt-instructions/SKILL.md',\n );\n if (!text.trim()) throw new Error('The installed ChatGPT instruction skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_NATIVE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-native-extension/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-native-extension/SKILL.md');\n if (!text.trim()) throw new Error('The installed native extension skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CODEMODE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-codemode-plugin/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/help-how-to-codemode-plugin/SKILL.md');\n if (!text.trim()) throw new Error('The installed code-mode plugin skill is missing or unreadable.');\n return text;\n },\n },\n // Pinned like every code-mode guide, but listed only where the host can reload and Help is on.\n ...(selfImprove === undefined\n ? []\n : [\n {\n when: HELP_WHEN,\n ...HELP_SELF_IMPROVE_SKILL,\n kind: 'skill' as const,\n pinned: true,\n path: packageResourcePath(import.meta.url, 'src/prompts/codemode-how-to-self-improve/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/codemode-how-to-self-improve/SKILL.md'),\n },\n ]),\n ];\n const selectMode = async (enabled: boolean, signal?: AbortSignal): Promise<void> => {\n if (disposed) throw new Error('Help runtime is disposed.');\n signal?.throwIfAborted();\n const operation = ++generation;\n pending = enabled;\n failure = undefined;\n modeOwner?.publish();\n try {\n if (enabled) await resources[1]!.read(host.context);\n signal?.throwIfAborted();\n if (operation !== generation || disposed) throw new Error('Help activation was cancelled.');\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== HELP_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, HELP_MODE_ID] : modes,\n });\n } catch (error) {\n if (operation === generation) failure = (error instanceof Error ? error.message : String(error)).slice(0, 160);\n throw error;\n } finally {\n if (operation === generation) {\n pending = undefined;\n modeOwner?.publish();\n }\n }\n };\n const command: PoHeadlessCommand = {\n name: HELP_COMMAND_NAME,\n description: HELP_COMMAND_DESCRIPTION,\n async execute(_args, execution) {\n await selectMode(!(pending ?? active()));\n await execution.client.notify({\n title: 'Po Help',\n body: active() ? 'Help mode activated.' : 'Help mode deactivated.',\n level: 'info',\n });\n },\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: HELP_PACKAGE_SOURCE,\n id: HELP_MODE_ID,\n label: 'Help',\n description: 'Package guidance and read-only diagnostics for agent setup and debugging.',\n order: 50,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Expose Help guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Withdraw Help-only guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, _argumentsValue, { signal }) {\n if (actionId !== 'activate' && actionId !== 'deactivate')\n throw new Error(`Unknown Help mode action: ${actionId}`);\n await selectMode(actionId === 'activate', signal);\n return { message: active() ? 'Help mode activated.' : 'Help mode deactivated.' };\n },\n }).createOwner(undefined);\n const assertHelpActive = () => {\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n };\n // Registered only while Help is on: the activity starts with Help and stops when it is withdrawn.\n const selfImproveService = (cordis: PoServerPluginContext['context']) => {\n cordis.inject([PO_CODEMODE_SERVICE], (scoped) => {\n const codemode = readPoCodemode(scoped);\n if (!codemode || !selfImprove) return undefined;\n const namespace = createSelfImproveNamespace({\n sessionId: host.context.sessionId,\n service: selfImprove,\n failures: packageFailures,\n assertActive: assertHelpActive,\n admitMessage: host.context.session.admitMessage?.bind(host.context.session),\n });\n const activity = host.registerActivity({\n when: HELP_WHEN,\n name: 'selfImprove',\n start: () => {\n const registration = codemode.register(HELP_PACKAGE_SOURCE, namespace);\n return () => registration.dispose();\n },\n });\n return () => activity.dispose();\n });\n };\n return {\n services: [serverMinorModes([modeOwner]), ...(selfImprove ? [selfImproveService] : [])],\n resources,\n commands: [command],\n tools: [\n createHelpStatusTool(inspect, (signal) => {\n signal?.throwIfAborted();\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n return signal ?? new AbortController().signal;\n }),\n ],\n onDispose() {\n disposed = true;\n generation += 1;\n },\n };\n}\n","import { readPoPackageHealth, readPoSelfImprove } from '@agimon-ai/po-core/help';\nimport type { PoServerPluginDefinition, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createHelpServerSession } from '../../../../../services/helpServerSession';\n\nexport default (({ agent, context }): Partial<PoServerSessionPlugin> =>\n agent\n ? createHelpServerSession(agent, () => readPoPackageHealth(context)?.failures() ?? [], readPoSelfImprove(context))\n : {}) satisfies NonNullable<PoServerPluginDefinition['session']>;\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport runtime from './_lib/runtime.server';\n\nexport default defineRoot((context: PoServerPluginContext) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n activities: value.activities,\n onStart: value.onStart,\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.commands?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\n// Present only where the host binds package reload; see createHelpServerSession.\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[5],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[4],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[3],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[2],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[1],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.tools?.[0],\n { cardinality: 'optional' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandPoHelp from '../src/extensions/workspaces/sessions/(backend)/command/po-help.server';\nimport resourceCodemodeHowToSelfImprove from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server';\nimport resourcePoDevelopCodemodePlugin from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server';\nimport resourcePoDevelopNativeExtension from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server';\nimport resourcePoHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-help.server';\nimport resourcePoUseChatgptInstructions from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server';\nimport resourcePoUseHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server';\nimport toolHelpStatus from '../src/extensions/workspaces/sessions/(backend)/tool/help_status.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-help',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'po-help' }, at(commandPoHelp, contextSession))]); },\n get resources(): PoServerSessionPlugin['resources'] { return defined([at(resourceCodemodeHowToSelfImprove, contextSession), at(resourcePoDevelopCodemodePlugin, contextSession), at(resourcePoDevelopNativeExtension, contextSession), at(resourcePoHelp, contextSession), at(resourcePoUseChatgptInstructions, contextSession), at(resourcePoUseHelp, contextSession)]); },\n get tools(): PoServerSessionPlugin['tools'] { return defined([via({ name: 'help_status' }, at(toolHelpStatus, contextSession))]); },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;AAAA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACx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GC,4BAAgB,cAAc,CAAC,CAAC,CAAC;GAAG;GAClI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-help",
3
- "version": "0.0.0-alpha.62",
3
+ "version": "0.0.0-alpha.63",
4
4
  "description": "Activation-gated package guidance and help skills for Po and Pi extensions.",
5
5
  "keywords": [
6
6
  "agent-documentation",
@@ -58,15 +58,15 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@agimon-ai/po-core": "0.0.0-alpha.62",
62
- "@agimon-ai/po-minor-mode": "0.0.0-alpha.62",
63
- "@agimon-ai/po-web-components": "0.0.0-alpha.62",
61
+ "@agimon-ai/po-core": "0.0.0-alpha.63",
62
+ "@agimon-ai/po-minor-mode": "0.0.0-alpha.63",
63
+ "@agimon-ai/po-web-components": "0.0.0-alpha.63",
64
64
  "@deepseek-ai/cordis": "4.0.5",
65
65
  "typebox": "1.4.2"
66
66
  },
67
67
  "devDependencies": {
68
- "@agimon-ai/po-build": "0.0.0-alpha.62",
69
- "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.62",
68
+ "@agimon-ai/po-build": "0.0.0-alpha.63",
69
+ "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.63",
70
70
  "@earendil-works/pi-coding-agent": "1.4.0",
71
71
  "@types/node": "26.6.5",
72
72
  "@types/react": "19.3.0",
@@ -15,8 +15,8 @@ description: "Reload Po's own packages, or refresh this session's mode, domain a
15
15
 
16
16
  ## Reloading
17
17
 
18
- 1. `selfImprove.reload({ scope })` returns `{ operationId, state: 'queued' }` at once. A session reload applies after the current tool round ends, so do not wait for it in the same `exec`.
19
- 2. In a later `exec`, read `selfImprove.operation(operationId)`:
18
+ 1. `selfImprove.reload({ scope })` returns `{ operationId, state: 'queued' }` at once. A session reload applies after the current tool round ends, so do not wait for it in the same `exec`. End the round; do not tell the person it is merely queued.
19
+ 2. When it finishes, Po sends you a follow-up message with the outcome. Pass it on to the person without being asked. `selfImprove.operation(operationId)` returns the same outcome in a later `exec`:
20
20
  - `applied`: every package installed. Installed packages no longer declared were removed (`result.removed`).
21
21
  - `partial`: some packages failed (`result.failed`) and keep their previous build when they had one.
22
22
  - `failed`: nothing changed; `error` says why.
@@ -26,7 +26,7 @@ description: "Reload Po's own packages, or refresh this session's mode, domain a
26
26
 
27
27
  ## Refreshing config
28
28
 
29
- After editing `modes.yaml`, a domain, or a profile's env or binding, call `selfImprove.refresh({ axes })` with any of `'majorMode'`, `'domains'`, `'profile'` (default: all three). It re-applies the session's current names from disk, so no rename or reopen is needed. It is queued like a reload and applies after the current tool round; read `operation(operationId)` in a later `exec`. A `profile` refresh reconnects its secret provider.
29
+ After editing `modes.yaml`, a domain, or a profile's env or binding, call `selfImprove.refresh({ axes })` with any of `'majorMode'`, `'domains'`, `'profile'` (default: all three). It re-applies the session's current names from disk, so no rename or reopen is needed. It is queued like a reload, applies after the current tool round, and reports its outcome the same way. A `profile` refresh reconnects its secret provider.
30
30
 
31
31
  Domain code-mode scripts load once when the session opens; a new or changed domain script needs the session reopened.
32
32