@agimon-ai/po-profile 0.0.0-alpha.36 → 0.0.0-alpha.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,20 +2,32 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_profileText = require("../profileText-B5b3tlUP.cjs");
5
+ const require_profileText = require("../profileText-BSaTvVwa.cjs");
6
6
  let _agimon_ai_po_config_profiles = require("@agimon-ai/po-config/profiles");
7
7
  let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
8
8
  let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
9
- let _agimon_ai_po_core_headless = require("@agimon-ai/po-core/headless");
10
9
  let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
10
+ let _agimon_ai_po_core_headless = require("@agimon-ai/po-core/headless");
11
11
  let _agimon_ai_po_core_profileIdentity = require("@agimon-ai/po-core/profileIdentity");
12
+ //#region src/extensions/(backend)/root.server.ts
13
+ var root_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ host }) => {
14
+ const environment = Object.freeze({ ...host.context.environment });
15
+ const secrets = require_profileText.createProfileSecrets({ readBinding: (cwd, profile, homeDirectory) => (0, _agimon_ai_po_config_profiles.resolveProfile)(cwd, profile, homeDirectory ?? environment.HOME ?? _agimon_ai_po_core_platform.nodeHost.homeDirectory()).integration });
16
+ return {
17
+ value: secrets,
18
+ services: [require_profileText.createProfileSecretsPlugin(secrets)]
19
+ };
20
+ });
21
+ //#endregion
12
22
  //#region src/extensions/workspaces/sessions/(backend)/root.server.ts
13
23
  var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ agent, signal }) => {
14
24
  if (!agent) return { value: void 0 };
15
25
  const execution = agent.context;
26
+ const readProfile = (profileName) => (0, _agimon_ai_po_config_profiles.resolveProfile)(execution.repoRoot, profileName, execution.environment.HOME ?? _agimon_ai_po_core_platform.nodeHost.homeDirectory());
16
27
  const runtime = require_profileText.createProfileRuntime({
17
28
  profileName: execution.selection.profile,
18
- readBinding: (profileName) => (0, _agimon_ai_po_config_profiles.resolveProfile)(execution.repoRoot, profileName, execution.environment.HOME ?? _agimon_ai_po_core_platform.nodeHost.homeDirectory()).integration
29
+ readBinding: (profileName) => readProfile(profileName).integration,
30
+ readEnv: (profileName) => readProfile(profileName).env
19
31
  });
20
32
  const unsubscribe = agent.subscribeSelection(async (selection) => {
21
33
  try {
@@ -172,16 +184,39 @@ const via = (identity, value) => value === void 0 ? void 0 : {
172
184
  };
173
185
  const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
174
186
  name: "@agimon-ai/po-profile",
175
- providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default),
176
- injects: (0, _agimon_ai_po_core_extensionFile.composeRootInjects)({ session: [root_server_default] }),
187
+ providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default$1, root_server_default),
188
+ injects: (0, _agimon_ai_po_core_extensionFile.composeRootInjects)({
189
+ global: [root_server_default$1],
190
+ workspace: [root_server_default$1],
191
+ session: [root_server_default$1, root_server_default]
192
+ }),
193
+ global: async (context) => {
194
+ const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
195
+ return {
196
+ ...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal),
197
+ services: [...scopeGlobal.services ?? []]
198
+ };
199
+ },
200
+ workspace: async (context) => {
201
+ const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
202
+ return {
203
+ ...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal),
204
+ services: [...scopeGlobal.services ?? []]
205
+ };
206
+ },
177
207
  session: async (context) => {
178
- const scopeSession = await context.scopeRoot("session", root_server_default, context);
179
- const contextSession = {
208
+ const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
209
+ const contextGlobal = {
180
210
  ...context,
211
+ root: scopeGlobal.value
212
+ };
213
+ const scopeSession = await context.scopeRoot("session", root_server_default, contextGlobal);
214
+ const contextSession = {
215
+ ...contextGlobal,
181
216
  root: scopeSession.value
182
217
  };
183
218
  return {
184
- ...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeSession),
219
+ ...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal, scopeSession),
185
220
  get api() {
186
221
  return [at(route_server_default, contextSession)];
187
222
  },
@@ -194,9 +229,9 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
194
229
  get resources() {
195
230
  return [at(help_how_to_profile_server_default, contextSession), at(profileConfig_server_default, contextSession)];
196
231
  },
197
- services: [...scopeSession.services ?? []],
232
+ services: [...scopeGlobal.services ?? [], ...scopeSession.services ?? []],
198
233
  get activities() {
199
- return [...scopeSession.activities ?? []];
234
+ return [...scopeGlobal.activities ?? [], ...scopeSession.activities ?? []];
200
235
  }
201
236
  };
202
237
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","names":["defineRoot","createProfileRuntime","resolveProfile","nodeHost","PoHeadlessPromptAdmissionError","createProfileRuntimePlugin","runCleanups","defineRoute","resolveProfile","buildPersonaPrompt","PO_PROFILE_IDENTITY_ENTRY_TYPE","PROFILE_COMMAND","loadProfiles","profileTitle","profileItems","isPoHeadlessPromptAdmissionError","PoSessionSetupError","PoHeadlessPromptAdmissionError","defineRoutedContribution","defineHook","defineHook","defineResource","packageResourcePath","readPackageResource","defineResource","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","composeRootHooks","apiRoute","commandProfile","hookBeforeAgentStart","hookSessionStart","resourceHelpHowToProfile","resourceProfileConfig"],"sources":["../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/api/profile/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/profileServer.ts","../../src/extensions/workspaces/sessions/(backend)/command/profile.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/profileConfig.server.ts","../../generated/server.ts"],"sourcesContent":["import { resolveProfile } from '@agimon-ai/po-config/profiles';\nimport { defineRoot, runCleanups } from '@agimon-ai/po-core/extensionFile';\nimport { PoHeadlessPromptAdmissionError } from '@agimon-ai/po-core/headless';\nimport { nodeHost } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileRuntime, createProfileRuntimePlugin } from '../../../../services/profileRuntime';\n\nexport default defineRoot(({ agent, signal }: PoServerPluginContext) => {\n if (!agent) return { value: undefined };\n const execution = agent.context;\n const runtime = createProfileRuntime({\n profileName: execution.selection.profile,\n readBinding: (profileName) =>\n resolveProfile(execution.repoRoot, profileName, execution.environment.HOME ?? nodeHost.homeDirectory())\n .integration,\n });\n const unsubscribe = agent.subscribeSelection(async (selection) => {\n try {\n await runtime.select(selection.profile);\n } catch (error) {\n throw new PoHeadlessPromptAdmissionError(error);\n }\n });\n const invalidate = () => runtime.invalidate();\n signal.addEventListener('abort', invalidate, { once: true });\n if (signal.aborted) runtime.invalidate();\n return {\n value: runtime,\n services: [createProfileRuntimePlugin(runtime)],\n async onDispose() {\n await runCleanups(\n [unsubscribe, () => signal.removeEventListener('abort', invalidate), () => runtime.dispose()],\n 'Profile cleanup failed.',\n );\n },\n };\n});\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoute(({ agent }: PoServerPluginContext) => ({\n basePath: 'profile',\n start: () => ({\n fetch(request: Request) {\n if (new URL(request.url).pathname !== '/current') return Response.json({ error: 'Not found' }, { status: 404 });\n if (request.method !== 'GET')\n return Response.json({ error: 'Method not allowed' }, { status: 405, headers: { Allow: 'GET' } });\n if (!agent) return Response.json({ error: 'Session agent unavailable' }, { status: 404 });\n const selection = agent.context.selection;\n return Response.json({ profile: selection.profile ?? null });\n },\n close() {},\n }),\n}));\n","import { buildPersonaPrompt, loadProfiles, resolveProfile } from '@agimon-ai/po-config/profiles';\nimport {\n PoHeadlessPromptAdmissionError,\n PoSessionSetupError,\n isPoHeadlessPromptAdmissionError,\n type PoHeadlessCommand,\n type PoHeadlessExecutionContext,\n type PoHeadlessHostService,\n type PoHeadlessHook,\n} from '@agimon-ai/po-core/headless';\nimport { PO_PROFILE_IDENTITY_ENTRY_TYPE } from '@agimon-ai/po-core/profileIdentity';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { PROFILE_COMMAND, profileItems, profileTitle } from '../../../../../services/profileText';\n\nexport async function readSelectedPersona(execution: {\n readonly repoRoot: string;\n readonly selection: { readonly profile?: string };\n readonly environment?: Readonly<Record<string, string | undefined>>;\n}): Promise<string> {\n const name = execution.selection.profile;\n if (!name) return '(no active profile)';\n const profile = resolveProfile(execution.repoRoot, name, execution.environment?.HOME);\n const prompt = buildPersonaPrompt(profile.personaRoot, profile.persona);\n if (!prompt) throw new Error(`Profile \"${name}\" has no readable persona text`);\n return prompt;\n}\n\nasync function publishSelectedIdentity(execution: PoHeadlessExecutionContext, profile: string): Promise<void> {\n const identity = resolveProfile(execution.repoRoot, profile, execution.environment.HOME).identity;\n await execution.session.appendCustomEntry(PO_PROFILE_IDENTITY_ENTRY_TYPE, {\n profile,\n ...(identity?.name === undefined ? {} : { name: identity.name }),\n ...(identity?.icon === undefined ? {} : { icon: identity.icon }),\n });\n}\n\nexport function createProfileServerCommand(host: PoHeadlessHostService): PoHeadlessCommand {\n return {\n name: PROFILE_COMMAND,\n description: 'Show or change the active Po profile.',\n selectionRecovery: true,\n async execute(args, execution) {\n const profiles = loadProfiles(execution.repoRoot, execution.environment.HOME);\n let requested = args.trim();\n if (!requested) {\n const selected = await execution.client.request({\n kind: 'select',\n title: profileTitle(execution.selection.profile),\n options: profileItems(profiles),\n });\n if (typeof selected !== 'string' || !selected) return;\n requested = selected;\n }\n if (!profiles.some(({ name }) => name === requested)) throw new Error(`Unknown profile: ${requested}`);\n if (requested === execution.selection.profile && host.inspectCapabilities().ready) return;\n try {\n await host.changeSelection({ axis: 'profile', profile: requested });\n } catch (error) {\n if (isPoHeadlessPromptAdmissionError(error))\n throw new PoSessionSetupError(\n 'Profile integration is unavailable. Restore its credential or choose another profile.',\n );\n throw error;\n }\n await publishSelectedIdentity(execution, requested);\n },\n };\n}\nexport async function assertProfileReady(runtime: ProfileRuntime | undefined): Promise<void> {\n try {\n await runtime?.ready();\n } catch (error) {\n // Ordinary hook failures are advisory. This is a fail-closed admission boundary.\n throw new PoHeadlessPromptAdmissionError(error);\n }\n}\n\nexport const profileIdentityHook: PoHeadlessHook<'session_start'> = {\n event: 'session_start',\n async handle(_event, execution) {\n const profile = execution.selection.profile;\n if (profile !== undefined) await publishSelectedIdentity(execution, profile);\n },\n};\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileServerCommand } from '../_lib/profileServer';\nexport default defineRoutedContribution(\n ({ agent }: PoServerPluginContext) => (agent ? createProfileServerCommand(agent) : undefined),\n { cardinality: 'optional' },\n);\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { assertProfileReady } from '../_lib/profileServer';\n\nexport default defineHook(({ root }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => ({\n async handle() {\n await assertProfileReady(root);\n },\n}));\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoHeadlessExecutionContext } from '@agimon-ai/po-core/headless';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { assertProfileReady, profileIdentityHook } from '../_lib/profileServer';\n\nexport default defineHook(({ root }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => ({\n ...profileIdentityHook,\n async handle(event: Readonly<Record<string, unknown>>, execution: PoHeadlessExecutionContext) {\n await assertProfileReady(root);\n await profileIdentityHook.handle(event, execution);\n },\n}));\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n name: 'help-how-to-profile',\n description:\n 'Configure Po profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.',\n when: { state: { 'minor-mode': 'help' }, attribution: { kind: 'minor' as const, mode: 'help' } },\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-profile/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-profile/SKILL.md'),\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\n\nimport { readSelectedPersona } from '../_lib/profileServer';\nexport default defineResource({ name: 'po/profile-config', kind: 'context' as const, read: readSelectedPersona });\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 apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/profile/route.server';\nimport commandProfile from '../src/extensions/workspaces/sessions/(backend)/command/profile.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server';\nimport resourceHelpHowToProfile from '../src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server';\nimport resourceProfileConfig from '../src/extensions/workspaces/sessions/(backend)/resource/profileConfig.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-profile',\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 api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'profile' }, at(commandProfile, contextSession))]); },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'session_start' }, at(hookSessionStart, contextSession))]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceHelpHowToProfile, contextSession), at(resourceProfileConfig, contextSession)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;AAQA,IAAA,uBAAA,GAAeA,iCAAAA,WAAAA,EAAY,EAAE,OAAO,aAAoC;CACtE,IAAI,CAAC,OAAO,OAAO,EAAE,OAAO,KAAA,EAAU;CACtC,MAAM,YAAY,MAAM;CACxB,M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GAAG;GACpI,IAAI,QAAwC;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,iCAAsB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,gBAAgB,GAAG,GAAGC,6BAAkB,cAAc,CAAC,CAAC;GAAG;GAC9M,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGC,oCAA0B,cAAc,GAAG,GAAGC,8BAAuB,cAAc,CAAC;GAAG;GACxJ,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.cjs","names":["defineRoot","createProfileSecrets","resolveProfile","nodeHost","createProfileSecretsPlugin","defineRoot","resolveProfile","nodeHost","createProfileRuntime","PoHeadlessPromptAdmissionError","createProfileRuntimePlugin","runCleanups","defineRoute","resolveProfile","buildPersonaPrompt","PO_PROFILE_IDENTITY_ENTRY_TYPE","PROFILE_COMMAND","loadProfiles","profileTitle","profileItems","isPoHeadlessPromptAdmissionError","PoSessionSetupError","PoHeadlessPromptAdmissionError","defineRoutedContribution","defineHook","defineHook","defineResource","packageResourcePath","readPackageResource","defineResource","defineServerPlugin","composeServerProviderOverrides","rootGlobal","rootSession","composeRootInjects","composeRootHooks","apiRoute","commandProfile","hookBeforeAgentStart","hookSessionStart","resourceHelpHowToProfile","resourceProfileConfig"],"sources":["../../src/extensions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/api/profile/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/profileServer.ts","../../src/extensions/workspaces/sessions/(backend)/command/profile.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/profileConfig.server.ts","../../generated/server.ts"],"sourcesContent":["import { resolveProfile } from '@agimon-ai/po-config/profiles';\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { nodeHost } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileSecrets, createProfileSecretsPlugin } from '../../services/profileSecrets';\n\nexport default defineRoot(({ host }: PoServerPluginContext) => {\n const environment = Object.freeze({ ...host.context.environment });\n const secrets = createProfileSecrets({\n readBinding: (cwd, profile, homeDirectory) =>\n resolveProfile(cwd, profile, homeDirectory ?? environment.HOME ?? nodeHost.homeDirectory()).integration,\n });\n return { value: secrets, services: [createProfileSecretsPlugin(secrets)] };\n});\n","import { resolveProfile } from '@agimon-ai/po-config/profiles';\nimport { defineRoot, runCleanups } from '@agimon-ai/po-core/extensionFile';\nimport { PoHeadlessPromptAdmissionError } from '@agimon-ai/po-core/headless';\nimport { nodeHost } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileRuntime, createProfileRuntimePlugin } from '../../../../services/profileRuntime';\n\nexport default defineRoot(({ agent, signal }: PoServerPluginContext) => {\n if (!agent) return { value: undefined };\n const execution = agent.context;\n const readProfile = (profileName: string) =>\n resolveProfile(execution.repoRoot, profileName, execution.environment.HOME ?? nodeHost.homeDirectory());\n const runtime = createProfileRuntime({\n profileName: execution.selection.profile,\n readBinding: (profileName) => readProfile(profileName).integration,\n readEnv: (profileName) => readProfile(profileName).env,\n });\n const unsubscribe = agent.subscribeSelection(async (selection) => {\n try {\n await runtime.select(selection.profile);\n } catch (error) {\n throw new PoHeadlessPromptAdmissionError(error);\n }\n });\n const invalidate = () => runtime.invalidate();\n signal.addEventListener('abort', invalidate, { once: true });\n if (signal.aborted) runtime.invalidate();\n return {\n value: runtime,\n services: [createProfileRuntimePlugin(runtime)],\n async onDispose() {\n await runCleanups(\n [unsubscribe, () => signal.removeEventListener('abort', invalidate), () => runtime.dispose()],\n 'Profile cleanup failed.',\n );\n },\n };\n});\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoute(({ agent }: PoServerPluginContext) => ({\n basePath: 'profile',\n start: () => ({\n fetch(request: Request) {\n if (new URL(request.url).pathname !== '/current') return Response.json({ error: 'Not found' }, { status: 404 });\n if (request.method !== 'GET')\n return Response.json({ error: 'Method not allowed' }, { status: 405, headers: { Allow: 'GET' } });\n if (!agent) return Response.json({ error: 'Session agent unavailable' }, { status: 404 });\n const selection = agent.context.selection;\n return Response.json({ profile: selection.profile ?? null });\n },\n close() {},\n }),\n}));\n","import { buildPersonaPrompt, loadProfiles, resolveProfile } from '@agimon-ai/po-config/profiles';\nimport {\n PoHeadlessPromptAdmissionError,\n PoSessionSetupError,\n isPoHeadlessPromptAdmissionError,\n type PoHeadlessCommand,\n type PoHeadlessExecutionContext,\n type PoHeadlessHostService,\n type PoHeadlessHook,\n} from '@agimon-ai/po-core/headless';\nimport { PO_PROFILE_IDENTITY_ENTRY_TYPE } from '@agimon-ai/po-core/profileIdentity';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { PROFILE_COMMAND, profileItems, profileTitle } from '../../../../../services/profileText';\n\nexport async function readSelectedPersona(execution: {\n readonly repoRoot: string;\n readonly selection: { readonly profile?: string };\n readonly environment?: Readonly<Record<string, string | undefined>>;\n}): Promise<string> {\n const name = execution.selection.profile;\n if (!name) return '(no active profile)';\n const profile = resolveProfile(execution.repoRoot, name, execution.environment?.HOME);\n const prompt = buildPersonaPrompt(profile.personaRoot, profile.persona);\n if (!prompt) throw new Error(`Profile \"${name}\" has no readable persona text`);\n return prompt;\n}\n\nasync function publishSelectedIdentity(execution: PoHeadlessExecutionContext, profile: string): Promise<void> {\n const identity = resolveProfile(execution.repoRoot, profile, execution.environment.HOME).identity;\n await execution.session.appendCustomEntry(PO_PROFILE_IDENTITY_ENTRY_TYPE, {\n profile,\n ...(identity?.name === undefined ? {} : { name: identity.name }),\n ...(identity?.icon === undefined ? {} : { icon: identity.icon }),\n });\n}\n\nexport function createProfileServerCommand(host: PoHeadlessHostService): PoHeadlessCommand {\n return {\n name: PROFILE_COMMAND,\n description: 'Show or change the active Po profile.',\n selectionRecovery: true,\n async execute(args, execution) {\n const profiles = loadProfiles(execution.repoRoot, execution.environment.HOME);\n let requested = args.trim();\n if (!requested) {\n const selected = await execution.client.request({\n kind: 'select',\n title: profileTitle(execution.selection.profile),\n options: profileItems(profiles),\n });\n if (typeof selected !== 'string' || !selected) return;\n requested = selected;\n }\n if (!profiles.some(({ name }) => name === requested)) throw new Error(`Unknown profile: ${requested}`);\n if (requested === execution.selection.profile && host.inspectCapabilities().ready) return;\n try {\n await host.changeSelection({ axis: 'profile', profile: requested });\n } catch (error) {\n if (isPoHeadlessPromptAdmissionError(error))\n throw new PoSessionSetupError(\n 'Profile integration is unavailable. Restore its credential or choose another profile.',\n );\n throw error;\n }\n await publishSelectedIdentity(execution, requested);\n },\n };\n}\nexport async function assertProfileReady(runtime: ProfileRuntime | undefined): Promise<void> {\n try {\n await runtime?.ready();\n } catch (error) {\n // Ordinary hook failures are advisory. This is a fail-closed admission boundary.\n throw new PoHeadlessPromptAdmissionError(error);\n }\n}\n\nexport const profileIdentityHook: PoHeadlessHook<'session_start'> = {\n event: 'session_start',\n async handle(_event, execution) {\n const profile = execution.selection.profile;\n if (profile !== undefined) await publishSelectedIdentity(execution, profile);\n },\n};\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileServerCommand } from '../_lib/profileServer';\nexport default defineRoutedContribution(\n ({ agent }: PoServerPluginContext) => (agent ? createProfileServerCommand(agent) : undefined),\n { cardinality: 'optional' },\n);\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { assertProfileReady } from '../_lib/profileServer';\n\nexport default defineHook(({ root }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => ({\n async handle() {\n await assertProfileReady(root);\n },\n}));\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoHeadlessExecutionContext } from '@agimon-ai/po-core/headless';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { assertProfileReady, profileIdentityHook } from '../_lib/profileServer';\n\nexport default defineHook(({ root }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => ({\n ...profileIdentityHook,\n async handle(event: Readonly<Record<string, unknown>>, execution: PoHeadlessExecutionContext) {\n await assertProfileReady(root);\n await profileIdentityHook.handle(event, execution);\n },\n}));\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n name: 'help-how-to-profile',\n description:\n 'Configure Po profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.',\n when: { state: { 'minor-mode': 'help' }, attribution: { kind: 'minor' as const, mode: 'help' } },\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-profile/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-profile/SKILL.md'),\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\n\nimport { readSelectedPersona } from '../_lib/profileServer';\nexport default defineResource({ name: 'po/profile-config', kind: 'context' as const, read: readSelectedPersona });\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 rootGlobal from '../src/extensions/(backend)/root.server';\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/profile/route.server';\nimport commandProfile from '../src/extensions/workspaces/sessions/(backend)/command/profile.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server';\nimport resourceHelpHowToProfile from '../src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server';\nimport resourceProfileConfig from '../src/extensions/workspaces/sessions/(backend)/resource/profileConfig.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-profile',\n providerOverrides: composeServerProviderOverrides(rootGlobal, rootSession),\n injects: composeRootInjects({ global: [rootGlobal], workspace: [rootGlobal], session: [rootGlobal, rootSession] }),\n global: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n workspace: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n session: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n const contextGlobal = { ...context, root: scopeGlobal.value };\n const scopeSession = await context.scopeRoot('session', rootSession, contextGlobal);\n const contextSession = { ...contextGlobal, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeGlobal, scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'profile' }, at(commandProfile, contextSession))]); },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'session_start' }, at(hookSessionStart, contextSession))]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceHelpHowToProfile, contextSession), at(resourceProfileConfig, contextSession)]; },\n services: [...(scopeGlobal.services ?? []), ...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeGlobal.activities ?? []), ...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;AAOA,IAAA,yBAAA,GAAeA,iCAAAA,WAAAA,EAAY,EAAE,WAAkC;CAC7D,MAAM,cAAc,OAAO,OAAO,EAAE,GAAG,KAAK,QAAQ,YAAY,CAAC;CACjE,MAAM,UAAUC,oBAAAA,qBAAqB,EACnC,cAAc,KAAK,SAAS,mBAAA,GAC1BC,8BAAAA,eAAAA,CAAe,KAAK,SAAS,iBAAiB,YAAY,QAAQC,4BAAAA,SAAS,cAAc,CAAC,CAAC,CAAC,YAChG,CAAC;CACD,OAAO;EAAE,OAAO;EAAS,UAAU,CAACC,oBAAAA,2BAA2B,OAAO,CAAC;CAAE;AAC3E,CAAC;;;ACND,IAAA,uBAAA,GAAeC,iCAAAA,WAAAA,EAAY,EAAE,OAAO,aAAoC;CACtE,IAAI,CAAC,OAAO,OAAO,EAAE,OAAO,KAAA,EAAU;CACtC,MAAM,YAAY,MAAM;CACxB,MAAM,eAAe,iBAAA,GACnBC,8BAAAA,eAAAA,CAAe,UAAU,UAAU,aAAa,UAAU,YAAY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,GAAGG,iCAAAA,iBAAAA,CAAiB,WAAW;GAC/B,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,CAAE;EAC5C;CACF;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,cAAc,MAAM,QAAQ,UAAU,UAAUH,uBAAY,OAAO;EACzE,MAAM,gBAAgB;GAAE,GAAG;GAAS,MAAM,YAAY;EAAM;EAC5D,MAAM,eAAe,MAAM,QAAQ,UAAU,WAAWC,qBAAa,aAAa;EAClF,MAAM,iBAAiB;GAAE,GAAG;GAAe,MAAM,aAAa;EAAM;EACpE,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,aAAa,YAAY;GAC7C,IAAI,MAAoC;IAAE,OAAO,CAAC,GAAGC,sBAAU,cAAc,CAAC;GAAG;GACjF,IAAI,WAA8C;IAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,UAAU,GAAG,GAAGC,wBAAgB,cAAc,CAAC,CAAC,CAAC;GAAG;GACpI,IAAI,QAAwC;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,iCAAsB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,gBAAgB,GAAG,GAAGC,6BAAkB,cAAc,CAAC,CAAC;GAAG;GAC9M,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGC,oCAA0B,cAAc,GAAG,GAAGC,8BAAuB,cAAc,CAAC;GAAG;GACxJ,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,GAAI,GAAI,aAAa,YAAY,CAAC,CAAE;GAC5E,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,YAAY,cAAc,CAAC,GAAI,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EAC1I;CACF;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAsBa,wDAAY"}
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAuBa,wDAAY"}
@@ -1,17 +1,29 @@
1
- import { c as createProfileRuntime, i as profileItems, l as createProfileRuntimePlugin, s as profileTitle, t as PROFILE_COMMAND } from "../profileText-lvcGhQ4l.mjs";
1
+ import { f as createProfileRuntime, i as profileItems, l as createProfileSecrets, p as createProfileRuntimePlugin, s as profileTitle, t as PROFILE_COMMAND, u as createProfileSecretsPlugin } from "../profileText-BSQET_iz.mjs";
2
2
  import { buildPersonaPrompt, loadProfiles, resolveProfile } from "@agimon-ai/po-config/profiles";
3
3
  import { composeServerProviderOverrides, defineServerPlugin, packageResourcePath, readPackageResource } from "@agimon-ai/po-core/serverPlugin";
4
4
  import { composeRootHooks, composeRootInjects, defineHook, defineResource, defineRoot, defineRoute, defineRoutedContribution, runCleanups } from "@agimon-ai/po-core/extensionFile";
5
- import { PoHeadlessPromptAdmissionError, PoSessionSetupError, isPoHeadlessPromptAdmissionError } from "@agimon-ai/po-core/headless";
6
5
  import { nodeHost } from "@agimon-ai/po-core/platform";
6
+ import { PoHeadlessPromptAdmissionError, PoSessionSetupError, isPoHeadlessPromptAdmissionError } from "@agimon-ai/po-core/headless";
7
7
  import { PO_PROFILE_IDENTITY_ENTRY_TYPE } from "@agimon-ai/po-core/profileIdentity";
8
+ //#region src/extensions/(backend)/root.server.ts
9
+ var root_server_default$1 = defineRoot(({ host }) => {
10
+ const environment = Object.freeze({ ...host.context.environment });
11
+ const secrets = createProfileSecrets({ readBinding: (cwd, profile, homeDirectory) => resolveProfile(cwd, profile, homeDirectory ?? environment.HOME ?? nodeHost.homeDirectory()).integration });
12
+ return {
13
+ value: secrets,
14
+ services: [createProfileSecretsPlugin(secrets)]
15
+ };
16
+ });
17
+ //#endregion
8
18
  //#region src/extensions/workspaces/sessions/(backend)/root.server.ts
9
19
  var root_server_default = defineRoot(({ agent, signal }) => {
10
20
  if (!agent) return { value: void 0 };
11
21
  const execution = agent.context;
22
+ const readProfile = (profileName) => resolveProfile(execution.repoRoot, profileName, execution.environment.HOME ?? nodeHost.homeDirectory());
12
23
  const runtime = createProfileRuntime({
13
24
  profileName: execution.selection.profile,
14
- readBinding: (profileName) => resolveProfile(execution.repoRoot, profileName, execution.environment.HOME ?? nodeHost.homeDirectory()).integration
25
+ readBinding: (profileName) => readProfile(profileName).integration,
26
+ readEnv: (profileName) => readProfile(profileName).env
15
27
  });
16
28
  const unsubscribe = agent.subscribeSelection(async (selection) => {
17
29
  try {
@@ -168,16 +180,39 @@ const via = (identity, value) => value === void 0 ? void 0 : {
168
180
  };
169
181
  const serverPlugin = defineServerPlugin({
170
182
  name: "@agimon-ai/po-profile",
171
- providerOverrides: composeServerProviderOverrides(root_server_default),
172
- injects: composeRootInjects({ session: [root_server_default] }),
183
+ providerOverrides: composeServerProviderOverrides(root_server_default$1, root_server_default),
184
+ injects: composeRootInjects({
185
+ global: [root_server_default$1],
186
+ workspace: [root_server_default$1],
187
+ session: [root_server_default$1, root_server_default]
188
+ }),
189
+ global: async (context) => {
190
+ const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
191
+ return {
192
+ ...composeRootHooks(scopeGlobal),
193
+ services: [...scopeGlobal.services ?? []]
194
+ };
195
+ },
196
+ workspace: async (context) => {
197
+ const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
198
+ return {
199
+ ...composeRootHooks(scopeGlobal),
200
+ services: [...scopeGlobal.services ?? []]
201
+ };
202
+ },
173
203
  session: async (context) => {
174
- const scopeSession = await context.scopeRoot("session", root_server_default, context);
175
- const contextSession = {
204
+ const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
205
+ const contextGlobal = {
176
206
  ...context,
207
+ root: scopeGlobal.value
208
+ };
209
+ const scopeSession = await context.scopeRoot("session", root_server_default, contextGlobal);
210
+ const contextSession = {
211
+ ...contextGlobal,
177
212
  root: scopeSession.value
178
213
  };
179
214
  return {
180
- ...composeRootHooks(scopeSession),
215
+ ...composeRootHooks(scopeGlobal, scopeSession),
181
216
  get api() {
182
217
  return [at(route_server_default, contextSession)];
183
218
  },
@@ -190,9 +225,9 @@ const serverPlugin = defineServerPlugin({
190
225
  get resources() {
191
226
  return [at(help_how_to_profile_server_default, contextSession), at(profileConfig_server_default, contextSession)];
192
227
  },
193
- services: [...scopeSession.services ?? []],
228
+ services: [...scopeGlobal.services ?? [], ...scopeSession.services ?? []],
194
229
  get activities() {
195
- return [...scopeSession.activities ?? []];
230
+ return [...scopeGlobal.activities ?? [], ...scopeSession.activities ?? []];
196
231
  }
197
232
  };
198
233
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.mjs","names":["rootSession","apiRoute","commandProfile","hookBeforeAgentStart","hookSessionStart","resourceHelpHowToProfile","resourceProfileConfig"],"sources":["../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/api/profile/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/profileServer.ts","../../src/extensions/workspaces/sessions/(backend)/command/profile.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/profileConfig.server.ts","../../generated/server.ts"],"sourcesContent":["import { resolveProfile } from '@agimon-ai/po-config/profiles';\nimport { defineRoot, runCleanups } from '@agimon-ai/po-core/extensionFile';\nimport { PoHeadlessPromptAdmissionError } from '@agimon-ai/po-core/headless';\nimport { nodeHost } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileRuntime, createProfileRuntimePlugin } from '../../../../services/profileRuntime';\n\nexport default defineRoot(({ agent, signal }: PoServerPluginContext) => {\n if (!agent) return { value: undefined };\n const execution = agent.context;\n const runtime = createProfileRuntime({\n profileName: execution.selection.profile,\n readBinding: (profileName) =>\n resolveProfile(execution.repoRoot, profileName, execution.environment.HOME ?? nodeHost.homeDirectory())\n .integration,\n });\n const unsubscribe = agent.subscribeSelection(async (selection) => {\n try {\n await runtime.select(selection.profile);\n } catch (error) {\n throw new PoHeadlessPromptAdmissionError(error);\n }\n });\n const invalidate = () => runtime.invalidate();\n signal.addEventListener('abort', invalidate, { once: true });\n if (signal.aborted) runtime.invalidate();\n return {\n value: runtime,\n services: [createProfileRuntimePlugin(runtime)],\n async onDispose() {\n await runCleanups(\n [unsubscribe, () => signal.removeEventListener('abort', invalidate), () => runtime.dispose()],\n 'Profile cleanup failed.',\n );\n },\n };\n});\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoute(({ agent }: PoServerPluginContext) => ({\n basePath: 'profile',\n start: () => ({\n fetch(request: Request) {\n if (new URL(request.url).pathname !== '/current') return Response.json({ error: 'Not found' }, { status: 404 });\n if (request.method !== 'GET')\n return Response.json({ error: 'Method not allowed' }, { status: 405, headers: { Allow: 'GET' } });\n if (!agent) return Response.json({ error: 'Session agent unavailable' }, { status: 404 });\n const selection = agent.context.selection;\n return Response.json({ profile: selection.profile ?? null });\n },\n close() {},\n }),\n}));\n","import { buildPersonaPrompt, loadProfiles, resolveProfile } from '@agimon-ai/po-config/profiles';\nimport {\n PoHeadlessPromptAdmissionError,\n PoSessionSetupError,\n isPoHeadlessPromptAdmissionError,\n type PoHeadlessCommand,\n type PoHeadlessExecutionContext,\n type PoHeadlessHostService,\n type PoHeadlessHook,\n} from '@agimon-ai/po-core/headless';\nimport { PO_PROFILE_IDENTITY_ENTRY_TYPE } from '@agimon-ai/po-core/profileIdentity';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { PROFILE_COMMAND, profileItems, profileTitle } from '../../../../../services/profileText';\n\nexport async function readSelectedPersona(execution: {\n readonly repoRoot: string;\n readonly selection: { readonly profile?: string };\n readonly environment?: Readonly<Record<string, string | undefined>>;\n}): Promise<string> {\n const name = execution.selection.profile;\n if (!name) return '(no active profile)';\n const profile = resolveProfile(execution.repoRoot, name, execution.environment?.HOME);\n const prompt = buildPersonaPrompt(profile.personaRoot, profile.persona);\n if (!prompt) throw new Error(`Profile \"${name}\" has no readable persona text`);\n return prompt;\n}\n\nasync function publishSelectedIdentity(execution: PoHeadlessExecutionContext, profile: string): Promise<void> {\n const identity = resolveProfile(execution.repoRoot, profile, execution.environment.HOME).identity;\n await execution.session.appendCustomEntry(PO_PROFILE_IDENTITY_ENTRY_TYPE, {\n profile,\n ...(identity?.name === undefined ? {} : { name: identity.name }),\n ...(identity?.icon === undefined ? {} : { icon: identity.icon }),\n });\n}\n\nexport function createProfileServerCommand(host: PoHeadlessHostService): PoHeadlessCommand {\n return {\n name: PROFILE_COMMAND,\n description: 'Show or change the active Po profile.',\n selectionRecovery: true,\n async execute(args, execution) {\n const profiles = loadProfiles(execution.repoRoot, execution.environment.HOME);\n let requested = args.trim();\n if (!requested) {\n const selected = await execution.client.request({\n kind: 'select',\n title: profileTitle(execution.selection.profile),\n options: profileItems(profiles),\n });\n if (typeof selected !== 'string' || !selected) return;\n requested = selected;\n }\n if (!profiles.some(({ name }) => name === requested)) throw new Error(`Unknown profile: ${requested}`);\n if (requested === execution.selection.profile && host.inspectCapabilities().ready) return;\n try {\n await host.changeSelection({ axis: 'profile', profile: requested });\n } catch (error) {\n if (isPoHeadlessPromptAdmissionError(error))\n throw new PoSessionSetupError(\n 'Profile integration is unavailable. Restore its credential or choose another profile.',\n );\n throw error;\n }\n await publishSelectedIdentity(execution, requested);\n },\n };\n}\nexport async function assertProfileReady(runtime: ProfileRuntime | undefined): Promise<void> {\n try {\n await runtime?.ready();\n } catch (error) {\n // Ordinary hook failures are advisory. This is a fail-closed admission boundary.\n throw new PoHeadlessPromptAdmissionError(error);\n }\n}\n\nexport const profileIdentityHook: PoHeadlessHook<'session_start'> = {\n event: 'session_start',\n async handle(_event, execution) {\n const profile = execution.selection.profile;\n if (profile !== undefined) await publishSelectedIdentity(execution, profile);\n },\n};\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileServerCommand } from '../_lib/profileServer';\nexport default defineRoutedContribution(\n ({ agent }: PoServerPluginContext) => (agent ? createProfileServerCommand(agent) : undefined),\n { cardinality: 'optional' },\n);\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { assertProfileReady } from '../_lib/profileServer';\n\nexport default defineHook(({ root }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => ({\n async handle() {\n await assertProfileReady(root);\n },\n}));\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoHeadlessExecutionContext } from '@agimon-ai/po-core/headless';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { assertProfileReady, profileIdentityHook } from '../_lib/profileServer';\n\nexport default defineHook(({ root }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => ({\n ...profileIdentityHook,\n async handle(event: Readonly<Record<string, unknown>>, execution: PoHeadlessExecutionContext) {\n await assertProfileReady(root);\n await profileIdentityHook.handle(event, execution);\n },\n}));\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n name: 'help-how-to-profile',\n description:\n 'Configure Po profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.',\n when: { state: { 'minor-mode': 'help' }, attribution: { kind: 'minor' as const, mode: 'help' } },\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-profile/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-profile/SKILL.md'),\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\n\nimport { readSelectedPersona } from '../_lib/profileServer';\nexport default defineResource({ name: 'po/profile-config', kind: 'context' as const, read: readSelectedPersona });\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 apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/profile/route.server';\nimport commandProfile from '../src/extensions/workspaces/sessions/(backend)/command/profile.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server';\nimport resourceHelpHowToProfile from '../src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server';\nimport resourceProfileConfig from '../src/extensions/workspaces/sessions/(backend)/resource/profileConfig.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-profile',\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 api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'profile' }, at(commandProfile, contextSession))]); },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'session_start' }, at(hookSessionStart, contextSession))]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceHelpHowToProfile, contextSession), at(resourceProfileConfig, contextSession)]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;AAQA,IAAA,sBAAe,YAAY,EAAE,OAAO,aAAoC;CACtE,IAAI,CAAC,OAAO,OAAO,EAAE,OAAO,KAAA,EAAU;CACtC,MAAM,YAAY,MAAM;CACxB,MAAM,UAAU,qBAAqB;EACnC,aAAa,UAAU,UAAU;EACjC,cAAc,gBACZ,eAAe,UAAU,UAAU,aAAa,UAAU,YAAY,QAAQ,SAAS,cAAc,CAAC,CAAC,CACpG;CACP,CAAC;CACD,MAAM,cAAc,MAAM,mBAAmB,OAAO,cAAc;EAChE,IAAI;GACF,MAAM,QAAQ,OAAO,UAAU,OAAO;EACxC,SAAS,OAAO;GACd,MAAM,IAAI,+BAA+B,KAAK;EAChD;CACF,CAAC;CACD,MAAM,mBAAmB,QAAQ,WAAW;CAC5C,OAAO,iBAAiB,SAAS,YAAY,EAAE,MAAM,KAAK,CAAC;CAC3D,IAAI,OAAO,SAAS,QAAQ,WAAW;CACvC,OAAO;EACL,OAAO;EACP,UAAU,CAAC,2BAA2B,OAAO,CAAC;EAC9C,MAAM,YAAY;GAChB,MAAM,YACJ;IAAC;UAAmB,OAAO,oBAAoB,SAAS,UAAU;UAAS,QAAQ,QAAQ;GAAC,GAC5F,yBACF;EACF;CACF;AACF,CAAC;;;AClCD,IAAA,uBAAe,aAAa,EAAE,aAAoC;CAChE,UAAU;CACV,cAAc;EACZ,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AAC,GAAG,IAAI,EAAE,OAAO,gBAAgB,GAAG,GAAGC,6BAAkB,cAAc,CAAC,CAAC;GAAG;GAC9M,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGC,oCAA0B,cAAc,GAAG,GAAGC,8BAAuB,cAAc,CAAC;GAAG;GACxJ,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.mjs","names":["rootGlobal","rootSession","apiRoute","commandProfile","hookBeforeAgentStart","hookSessionStart","resourceHelpHowToProfile","resourceProfileConfig"],"sources":["../../src/extensions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/api/profile/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/profileServer.ts","../../src/extensions/workspaces/sessions/(backend)/command/profile.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/profileConfig.server.ts","../../generated/server.ts"],"sourcesContent":["import { resolveProfile } from '@agimon-ai/po-config/profiles';\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport { nodeHost } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileSecrets, createProfileSecretsPlugin } from '../../services/profileSecrets';\n\nexport default defineRoot(({ host }: PoServerPluginContext) => {\n const environment = Object.freeze({ ...host.context.environment });\n const secrets = createProfileSecrets({\n readBinding: (cwd, profile, homeDirectory) =>\n resolveProfile(cwd, profile, homeDirectory ?? environment.HOME ?? nodeHost.homeDirectory()).integration,\n });\n return { value: secrets, services: [createProfileSecretsPlugin(secrets)] };\n});\n","import { resolveProfile } from '@agimon-ai/po-config/profiles';\nimport { defineRoot, runCleanups } from '@agimon-ai/po-core/extensionFile';\nimport { PoHeadlessPromptAdmissionError } from '@agimon-ai/po-core/headless';\nimport { nodeHost } from '@agimon-ai/po-core/platform';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileRuntime, createProfileRuntimePlugin } from '../../../../services/profileRuntime';\n\nexport default defineRoot(({ agent, signal }: PoServerPluginContext) => {\n if (!agent) return { value: undefined };\n const execution = agent.context;\n const readProfile = (profileName: string) =>\n resolveProfile(execution.repoRoot, profileName, execution.environment.HOME ?? nodeHost.homeDirectory());\n const runtime = createProfileRuntime({\n profileName: execution.selection.profile,\n readBinding: (profileName) => readProfile(profileName).integration,\n readEnv: (profileName) => readProfile(profileName).env,\n });\n const unsubscribe = agent.subscribeSelection(async (selection) => {\n try {\n await runtime.select(selection.profile);\n } catch (error) {\n throw new PoHeadlessPromptAdmissionError(error);\n }\n });\n const invalidate = () => runtime.invalidate();\n signal.addEventListener('abort', invalidate, { once: true });\n if (signal.aborted) runtime.invalidate();\n return {\n value: runtime,\n services: [createProfileRuntimePlugin(runtime)],\n async onDispose() {\n await runCleanups(\n [unsubscribe, () => signal.removeEventListener('abort', invalidate), () => runtime.dispose()],\n 'Profile cleanup failed.',\n );\n },\n };\n});\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineRoute(({ agent }: PoServerPluginContext) => ({\n basePath: 'profile',\n start: () => ({\n fetch(request: Request) {\n if (new URL(request.url).pathname !== '/current') return Response.json({ error: 'Not found' }, { status: 404 });\n if (request.method !== 'GET')\n return Response.json({ error: 'Method not allowed' }, { status: 405, headers: { Allow: 'GET' } });\n if (!agent) return Response.json({ error: 'Session agent unavailable' }, { status: 404 });\n const selection = agent.context.selection;\n return Response.json({ profile: selection.profile ?? null });\n },\n close() {},\n }),\n}));\n","import { buildPersonaPrompt, loadProfiles, resolveProfile } from '@agimon-ai/po-config/profiles';\nimport {\n PoHeadlessPromptAdmissionError,\n PoSessionSetupError,\n isPoHeadlessPromptAdmissionError,\n type PoHeadlessCommand,\n type PoHeadlessExecutionContext,\n type PoHeadlessHostService,\n type PoHeadlessHook,\n} from '@agimon-ai/po-core/headless';\nimport { PO_PROFILE_IDENTITY_ENTRY_TYPE } from '@agimon-ai/po-core/profileIdentity';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { PROFILE_COMMAND, profileItems, profileTitle } from '../../../../../services/profileText';\n\nexport async function readSelectedPersona(execution: {\n readonly repoRoot: string;\n readonly selection: { readonly profile?: string };\n readonly environment?: Readonly<Record<string, string | undefined>>;\n}): Promise<string> {\n const name = execution.selection.profile;\n if (!name) return '(no active profile)';\n const profile = resolveProfile(execution.repoRoot, name, execution.environment?.HOME);\n const prompt = buildPersonaPrompt(profile.personaRoot, profile.persona);\n if (!prompt) throw new Error(`Profile \"${name}\" has no readable persona text`);\n return prompt;\n}\n\nasync function publishSelectedIdentity(execution: PoHeadlessExecutionContext, profile: string): Promise<void> {\n const identity = resolveProfile(execution.repoRoot, profile, execution.environment.HOME).identity;\n await execution.session.appendCustomEntry(PO_PROFILE_IDENTITY_ENTRY_TYPE, {\n profile,\n ...(identity?.name === undefined ? {} : { name: identity.name }),\n ...(identity?.icon === undefined ? {} : { icon: identity.icon }),\n });\n}\n\nexport function createProfileServerCommand(host: PoHeadlessHostService): PoHeadlessCommand {\n return {\n name: PROFILE_COMMAND,\n description: 'Show or change the active Po profile.',\n selectionRecovery: true,\n async execute(args, execution) {\n const profiles = loadProfiles(execution.repoRoot, execution.environment.HOME);\n let requested = args.trim();\n if (!requested) {\n const selected = await execution.client.request({\n kind: 'select',\n title: profileTitle(execution.selection.profile),\n options: profileItems(profiles),\n });\n if (typeof selected !== 'string' || !selected) return;\n requested = selected;\n }\n if (!profiles.some(({ name }) => name === requested)) throw new Error(`Unknown profile: ${requested}`);\n if (requested === execution.selection.profile && host.inspectCapabilities().ready) return;\n try {\n await host.changeSelection({ axis: 'profile', profile: requested });\n } catch (error) {\n if (isPoHeadlessPromptAdmissionError(error))\n throw new PoSessionSetupError(\n 'Profile integration is unavailable. Restore its credential or choose another profile.',\n );\n throw error;\n }\n await publishSelectedIdentity(execution, requested);\n },\n };\n}\nexport async function assertProfileReady(runtime: ProfileRuntime | undefined): Promise<void> {\n try {\n await runtime?.ready();\n } catch (error) {\n // Ordinary hook failures are advisory. This is a fail-closed admission boundary.\n throw new PoHeadlessPromptAdmissionError(error);\n }\n}\n\nexport const profileIdentityHook: PoHeadlessHook<'session_start'> = {\n event: 'session_start',\n async handle(_event, execution) {\n const profile = execution.selection.profile;\n if (profile !== undefined) await publishSelectedIdentity(execution, profile);\n },\n};\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createProfileServerCommand } from '../_lib/profileServer';\nexport default defineRoutedContribution(\n ({ agent }: PoServerPluginContext) => (agent ? createProfileServerCommand(agent) : undefined),\n { cardinality: 'optional' },\n);\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { assertProfileReady } from '../_lib/profileServer';\n\nexport default defineHook(({ root }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => ({\n async handle() {\n await assertProfileReady(root);\n },\n}));\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoHeadlessExecutionContext } from '@agimon-ai/po-core/headless';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ProfileRuntime } from '../../../../../services/profileRuntime/type';\nimport { assertProfileReady, profileIdentityHook } from '../_lib/profileServer';\n\nexport default defineHook(({ root }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => ({\n ...profileIdentityHook,\n async handle(event: Readonly<Record<string, unknown>>, execution: PoHeadlessExecutionContext) {\n await assertProfileReady(root);\n await profileIdentityHook.handle(event, execution);\n },\n}));\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n name: 'help-how-to-profile',\n description:\n 'Configure Po profile discovery, personas, environment defaults, and precedence in profiles.yaml. Use when creating or changing personal or repository profiles. Do not use for config.yaml runtime settings, modes.yaml, or domains.yaml.',\n when: { state: { 'minor-mode': 'help' }, attribution: { kind: 'minor' as const, mode: 'help' } },\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/help-how-to-profile/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/help-how-to-profile/SKILL.md'),\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\n\nimport { readSelectedPersona } from '../_lib/profileServer';\nexport default defineResource({ name: 'po/profile-config', kind: 'context' as const, read: readSelectedPersona });\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 rootGlobal from '../src/extensions/(backend)/root.server';\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/profile/route.server';\nimport commandProfile from '../src/extensions/workspaces/sessions/(backend)/command/profile.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server';\nimport hookSessionStart from '../src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server';\nimport resourceHelpHowToProfile from '../src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server';\nimport resourceProfileConfig from '../src/extensions/workspaces/sessions/(backend)/resource/profileConfig.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-profile',\n providerOverrides: composeServerProviderOverrides(rootGlobal, rootSession),\n injects: composeRootInjects({ global: [rootGlobal], workspace: [rootGlobal], session: [rootGlobal, rootSession] }),\n global: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n workspace: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n session: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n const contextGlobal = { ...context, root: scopeGlobal.value };\n const scopeSession = await context.scopeRoot('session', rootSession, contextGlobal);\n const contextSession = { ...contextGlobal, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeGlobal, scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'profile' }, at(commandProfile, contextSession))]); },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'session_start' }, at(hookSessionStart, contextSession))]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceHelpHowToProfile, contextSession), at(resourceProfileConfig, contextSession)]; },\n services: [...(scopeGlobal.services ?? []), ...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeGlobal.activities ?? []), ...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;AAOA,IAAA,wBAAe,YAAY,EAAE,WAAkC;CAC7D,MAAM,cAAc,OAAO,OAAO,EAAE,GAAG,KAAK,QAAQ,YAAY,CAAC;CACjE,MAAM,UAAU,qBAAqB,EACnC,cAAc,KAAK,SAAS,kBAC1B,eAAe,KAAK,SAAS,iBAAiB,YAAY,QAAQ,SAAS,cAAc,CAAC,CAAC,CAAC,YAChG,CAAC;CACD,OAAO;EAAE,OAAO;EAAS,UAAU,CAAC,2BAA2B,OAAO,CAAC;CAAE;AAC3E,CAAC;;;ACND,IAAA,sBAAe,YAAY,EAAE,OAAO,aAAoC;CACtE,IAAI,CAAC,OAAO,OAAO,EAAE,OAAO,KAAA,EAAU;CACtC,MAAM,YAAY,MAAM;CACxB,MAAM,eAAe,gBACnB,eAAe,UAAU,UAAU,aAAa,UAAU,YAAY,QAAQ,SAAS,cAAc,CAAC;CACxG,MAAM,UAAU,qBAAqB;EACnC,aAAa,UAAU,UAAU;EACjC,cAAc,gBAAgB,YAAY,WAAW,CAAC,CAAC;EACvD,UAAU,gBAAgB,YAAY,WAAW,CAAC,CAAC;CACrD,CAAC;CACD,MAAM,cAAc,MAAM,mBAAmB,OAAO,cAAc;EAChE,IAAI;GACF,MAAM,QAAQ,OAAO,UAAU,OAAO;EACxC,SAAS,OAAO;GACd,MAAM,IAAI,+BAA+B,KAAK;EAChD;CACF,CAAC;CACD,MAAM,mBAAmB,QAAQ,WAAW;CAC5C,OAAO,iBAAiB,SAAS,YAAY,EAAE,MAAM,KAAK,CAAC;CAC3D,IAAI,OAAO,SAAS,QAAQ,WAAW;CACvC,OAAO;EACL,OAAO;EACP,UAAU,CAAC,2BAA2B,OAAO,CAAC;EAC9C,MAAM,YAAY;GAChB,MAAM,YACJ;IAAC;UAAmB,OAAO,oBAAoB,SAAS,UA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AO;EACzE,OAAO;GACL,GAAG,iBAAiB,WAAW;GAC/B,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,CAAE;EAC5C;CACF;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,cAAc,MAAM,QAAQ,UAAU,UAAUA,uBAAY,OAAO;EACzE,MAAM,gBAAgB;GAAE,GAAG;GAAS,MAAM,YAAY;EAAM;EAC5D,MAAM,eAAe,MAAM,QAAQ,UAAU,WAAWC,qBAAa,aAAa;EAClF,MAAM,iBAAiB;GAAE,GAAG;GAAe,MAAM,aAAa;EAAM;EACpE,OAAO;GACL,GAAG,iBAAiB,aAAa,YAAY;GAC7C,IAAI,MAAoC;IAAE,OAAO,CAAC,GAAGC,sBAAU,cAAc,CAAC;GAAG;GACjF,IAAI,WAA8C;IAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,UAAU,GAAG,GAAGC,wBAAgB,cAAc,CAAC,CAAC,CAAC;GAAG;GACpI,IAAI,QAAwC;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,iCAAsB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,gBAAgB,GAAG,GAAGC,6BAAkB,cAAc,CAAC,CAAC;GAAG;GAC9M,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGC,oCAA0B,cAAc,GAAG,GAAGC,8BAAuB,cAAc,CAAC;GAAG;GACxJ,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,GAAI,GAAI,aAAa,YAAY,CAAC,CAAE;GAC5E,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,YAAY,cAAc,CAAC,GAAI,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EAC1I;CACF;AACF,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,12 +1,85 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_profileText = require("./profileText-B5b3tlUP.cjs");
2
+ const require_profileText = require("./profileText-BSaTvVwa.cjs");
3
+ //#region src/services/secretRedaction/index.ts
4
+ const REDACTED = "[redacted]";
5
+ /** Raw, JSON-escaped and URL-encoded forms of every non-empty value. */
6
+ function secretForms(secrets) {
7
+ const forms = /* @__PURE__ */ new Set();
8
+ for (const secret of secrets) {
9
+ if (typeof secret !== "string" || !secret) continue;
10
+ forms.add(secret);
11
+ forms.add(JSON.stringify(secret).slice(1, -1));
12
+ forms.add(encodeURIComponent(secret));
13
+ }
14
+ return [...forms];
15
+ }
16
+ /** Marks every occurrence of every form, so overlapping secrets cannot leave fragments behind. */
17
+ function coverage(value, forms) {
18
+ const covered = new Uint8Array(value.length);
19
+ for (const form of forms) for (let index = value.indexOf(form); index !== -1; index = value.indexOf(form, index + 1)) covered.fill(1, index, index + form.length);
20
+ return covered;
21
+ }
22
+ function render(value, covered, end) {
23
+ let safe = "";
24
+ let start = 0;
25
+ for (let index = 0; index <= end; index++) {
26
+ if (index < end && covered[index] === covered[start]) continue;
27
+ if (index > start) safe += covered[start] ? REDACTED : value.slice(start, index);
28
+ start = index;
29
+ }
30
+ return safe;
31
+ }
32
+ function redactText(value, forms) {
33
+ return forms.length === 0 ? value : render(value, coverage(value, forms), value.length);
34
+ }
35
+ function redactValue(value, forms) {
36
+ if (typeof value === "string") return redactText(value, forms);
37
+ if (Array.isArray(value)) return value.map((entry) => redactValue(entry, forms));
38
+ if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, entry]) => [redactText(key, forms), redactValue(entry, forms)]));
39
+ return value;
40
+ }
41
+ /** Deeply redacts strings and object keys. Non-plain objects become plain records. */
42
+ function redactSecrets(value, secrets) {
43
+ return redactValue(value, secretForms(secrets));
44
+ }
45
+ function createSecretRedactionStream(secrets) {
46
+ const forms = secretForms(secrets);
47
+ const hold = Math.max(0, ...forms.map((form) => form.length - 1));
48
+ let buffer = "";
49
+ return {
50
+ write(chunk) {
51
+ buffer += chunk;
52
+ const covered = coverage(buffer, forms);
53
+ let end = Math.max(0, buffer.length - hold);
54
+ while (end > 0 && end < buffer.length && covered[end] && covered[end - 1]) end--;
55
+ const safe = render(buffer, covered, end);
56
+ buffer = buffer.slice(end);
57
+ return safe;
58
+ },
59
+ flush() {
60
+ const safe = redactText(buffer, forms);
61
+ buffer = "";
62
+ return safe;
63
+ }
64
+ };
65
+ }
66
+ //#endregion
3
67
  exports.PROFILE_RUNTIME_SERVICE = require_profileText.PROFILE_RUNTIME_SERVICE;
68
+ exports.PROFILE_SECRETS_SERVICE = require_profileText.PROFILE_SECRETS_SERVICE;
4
69
  exports.PROFILE_STATUS_KEY = require_profileText.PROFILE_STATUS_KEY;
70
+ exports.ProfileSecretsService = require_profileText.ProfileSecretsService;
5
71
  exports.createProfileRuntime = require_profileText.createProfileRuntime;
6
72
  exports.createProfileRuntimePlugin = require_profileText.createProfileRuntimePlugin;
73
+ exports.createProfileSecrets = require_profileText.createProfileSecrets;
74
+ exports.createProfileSecretsPlugin = require_profileText.createProfileSecretsPlugin;
75
+ exports.createSecretRedactionStream = createSecretRedactionStream;
7
76
  exports.profileDescription = require_profileText.profileDescription;
8
77
  exports.profileItems = require_profileText.profileItems;
9
78
  exports.profileStatus = require_profileText.profileStatus;
10
79
  exports.profileSummary = require_profileText.profileSummary;
11
80
  exports.profileTitle = require_profileText.profileTitle;
81
+ exports.redactSecrets = redactSecrets;
12
82
  exports.requireProfileRuntime = require_profileText.requireProfileRuntime;
83
+ exports.requireProfileSecrets = require_profileText.requireProfileSecrets;
84
+
85
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/services/secretRedaction/index.ts"],"sourcesContent":["// @scaffold-generated\nimport type { SecretRedactionStream } from './type';\n\nconst REDACTED = '[redacted]';\n\n/** Raw, JSON-escaped and URL-encoded forms of every non-empty value. */\nfunction secretForms(secrets: Iterable<string>): string[] {\n const forms = new Set<string>();\n for (const secret of secrets) {\n if (typeof secret !== 'string' || !secret) continue;\n forms.add(secret);\n forms.add(JSON.stringify(secret).slice(1, -1));\n forms.add(encodeURIComponent(secret));\n }\n return [...forms];\n}\n\n/** Marks every occurrence of every form, so overlapping secrets cannot leave fragments behind. */\nfunction coverage(value: string, forms: readonly string[]): Uint8Array {\n const covered = new Uint8Array(value.length);\n for (const form of forms)\n for (let index = value.indexOf(form); index !== -1; index = value.indexOf(form, index + 1))\n covered.fill(1, index, index + form.length);\n return covered;\n}\n\nfunction render(value: string, covered: Uint8Array, end: number): string {\n let safe = '';\n let start = 0;\n for (let index = 0; index <= end; index++) {\n if (index < end && covered[index] === covered[start]) continue;\n if (index > start) safe += covered[start] ? REDACTED : value.slice(start, index);\n start = index;\n }\n return safe;\n}\n\nfunction redactText(value: string, forms: readonly string[]): string {\n return forms.length === 0 ? value : render(value, coverage(value, forms), value.length);\n}\n\nfunction redactValue(value: unknown, forms: readonly string[]): unknown {\n if (typeof value === 'string') return redactText(value, forms);\n if (Array.isArray(value)) return value.map((entry) => redactValue(entry, forms));\n if (value !== null && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [redactText(key, forms), redactValue(entry, forms)]),\n );\n }\n return value;\n}\n\n/** Deeply redacts strings and object keys. Non-plain objects become plain records. */\nexport function redactSecrets<T>(value: T, secrets: Iterable<string>): T {\n return redactValue(value, secretForms(secrets)) as T;\n}\n\nexport function createSecretRedactionStream(secrets: Iterable<string>): SecretRedactionStream {\n const forms = secretForms(secrets);\n // A secret not yet complete must start within the last `hold` characters of the buffer.\n const hold = Math.max(0, ...forms.map((form) => form.length - 1));\n let buffer = '';\n return {\n write(chunk) {\n buffer += chunk;\n const covered = coverage(buffer, forms);\n let end = Math.max(0, buffer.length - hold);\n // Never split a completed match: hold back the whole run that crosses the boundary.\n while (end > 0 && end < buffer.length && covered[end] && covered[end - 1]) end--;\n const safe = render(buffer, covered, end);\n buffer = buffer.slice(end);\n return safe;\n },\n flush() {\n const safe = redactText(buffer, forms);\n buffer = '';\n return safe;\n },\n };\n}\n"],"mappings":";;;A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AAO,OAAO,YACZ,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,WAAW,KAAK,KAAK,GAAG,YAAY,OAAO,KAAK,CAAC,CAAC,CACjG;CAEF,OAAO;AACT;;AAGA,SAAgB,cAAiB,OAAU,SAA8B;CACvE,OAAO,YAAY,OAAO,YAAY,OAAO,CAAC;AAChD;AAEA,SAAgB,4BAA4B,SAAkD;CAC5F,MAAM,QAAQ,YAAY,OAAO;CAEjC,MAAM,OAAO,KAAK,IAAI,GAAG,GAAG,MAAM,KAAK,SAAS,KAAK,SAAS,CAAC,CAAC;CAChE,IAAI,SAAS;CACb,OAAO;EACL,MAAM,OAAO;GACX,UAAU;GACV,MAAM,UAAU,SAAS,QAAQ,KAAK;GACtC,IAAI,MAAM,KAAK,IAAI,GAAG,OAAO,SAAS,IAAI;GAE1C,OAAO,MAAM,KAAK,MAAM,OAAO,UAAU,QAAQ,QAAQ,QAAQ,MAAM,IAAI;GAC3E,MAAM,OAAO,OAAO,QAAQ,SAAS,GAAG;GACxC,SAAS,OAAO,MAAM,GAAG;GACzB,OAAO;EACT;EACA,QAAQ;GACN,MAAM,OAAO,WAAW,QAAQ,KAAK;GACrC,SAAS;GACT,OAAO;EACT;CACF;AACF"}
package/dist/index.d.mts CHANGED
@@ -1,12 +1,17 @@
1
1
  import { AgentProfile, ProfileIntegrationBinding, ProfileSecretReference } from "@agimon-ai/po-config/profiles";
2
- import { Context } from "@deepseek-ai/cordis";
2
+ import { Context, Service } from "@deepseek-ai/cordis";
3
3
  //#region src/constants/profileRuntime.d.ts
4
4
  export declare const PROFILE_RUNTIME_SERVICE = "po/profile-runtime";
5
5
  //#endregion
6
+ //#region src/constants/profileSecrets.d.ts
7
+ export declare const PROFILE_SECRETS_SERVICE = "po/profile-secrets";
8
+ //#endregion
6
9
  //#region src/services/profileRuntime/type.d.ts
7
10
  interface ProfileRuntimeSnapshot {
8
11
  readonly profileName?: string;
9
12
  readonly integration?: ProfileIntegrationBinding;
13
+ /** The profile's declared nonsecret env, the only names a `${env.NAME}` browser template may read. */
14
+ readonly env?: Readonly<Record<string, string>>;
10
15
  readonly generation: number;
11
16
  readonly signal: AbortSignal;
12
17
  }
@@ -32,7 +37,10 @@ interface ProfileRuntime {
32
37
  ready(): Promise<void>;
33
38
  /** One provider attachment per session. Returns an awaited cleanup/detach operation. */
34
39
  attachProvider(providerName: string, factory: ProfileProviderFactory): Promise<() => Promise<void>>;
40
+ /** Browser-purpose aliases only, for the trusted target-frame origin. */
35
41
  resolveSecret(name: string, request: ProfileSecretRequest): Promise<string>;
42
+ /** Host-only: the binding's `browser.proxySecret`, which must carry the proxy purpose. */
43
+ resolveProxySecret(signal?: AbortSignal): Promise<string>;
36
44
  select(profileName?: string): Promise<void>;
37
45
  /** Synchronous fence used when the owning scope aborts, before asynchronous disposal. */
38
46
  invalidate(): void;
@@ -42,6 +50,8 @@ interface ProfileRuntimeOptions {
42
50
  readonly profileName?: string;
43
51
  /** Reads only metadata. The runtime clones it before handing it to providers. */
44
52
  readonly readBinding: (profileName: string) => ProfileIntegrationBinding | undefined;
53
+ /** Reads the profile's declared nonsecret env. */
54
+ readonly readEnv?: (profileName: string) => Readonly<Record<string, string>> | undefined;
45
55
  }
46
56
  //#endregion
47
57
  //#region src/services/profileRuntime/index.d.ts
@@ -55,6 +65,60 @@ declare module '@deepseek-ai/cordis' {
55
65
  }
56
66
  }
57
67
  //#endregion
68
+ //#region src/services/profileSecrets/type.d.ts
69
+ interface ProfileEnvSecretRequest {
70
+ /** Repository the run executes in; its profile catalog is loaded for every request. */
71
+ readonly cwd: string;
72
+ readonly profile: string;
73
+ /** Aliases declared by the step. Each must carry the `env` purpose. */
74
+ readonly names: readonly string[];
75
+ readonly signal?: AbortSignal;
76
+ readonly homeDirectory?: string;
77
+ }
78
+ /** Host-only. Nothing here is exposed to the model; values go to a child process env only. */
79
+ interface ProfileSecrets {
80
+ /** One factory per provider name. Returns an unregister function. */
81
+ registerProvider(provider: string, factory: ProfileProviderFactory): () => void;
82
+ /** Resolves through a fresh provider connection and disposes it before returning. */
83
+ resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>>;
84
+ }
85
+ interface ProfileSecretsOptions {
86
+ /** Reads nonsecret metadata only, from the profile catalog for `cwd`. */
87
+ readonly readBinding: (cwd: string, profile: string, homeDirectory: string | undefined) => ProfileIntegrationBinding | undefined | Promise<ProfileIntegrationBinding | undefined>;
88
+ }
89
+ //#endregion
90
+ //#region src/services/profileSecrets/index.d.ts
91
+ export declare function createProfileSecrets(options: ProfileSecretsOptions): ProfileSecrets;
92
+ /** Host-side env secret resolution for workflow run steps. Never registered as a model tool. */
93
+ export declare class ProfileSecretsService extends Service implements ProfileSecrets {
94
+ private readonly source;
95
+ constructor(context: Context, source: ProfileSecrets);
96
+ registerProvider(provider: string, factory: ProfileProviderFactory): () => void;
97
+ resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>>;
98
+ }
99
+ /** Include in the extension services array. The helper owns the child fiber. */
100
+ export declare function createProfileSecretsPlugin(source: ProfileSecrets): (context: Context) => void;
101
+ export declare function requireProfileSecrets(context: Context): ProfileSecretsService;
102
+ declare module '@deepseek-ai/cordis' {
103
+ interface Context {
104
+ 'po/profile-secrets': ProfileSecretsService;
105
+ }
106
+ }
107
+ //#endregion
108
+ //#region src/services/secretRedaction/type.d.ts
109
+ /** Redacts chunked text without emitting a fragment of a secret split across chunks. */
110
+ interface SecretRedactionStream {
111
+ /** Returns the redacted text that is safe to emit; a possible secret prefix is held back. */
112
+ write(chunk: string): string;
113
+ /** Returns the redacted remainder. Call once when the source ends. */
114
+ flush(): string;
115
+ }
116
+ //#endregion
117
+ //#region src/services/secretRedaction/index.d.ts
118
+ /** Deeply redacts strings and object keys. Non-plain objects become plain records. */
119
+ export declare function redactSecrets<T>(value: T, secrets: Iterable<string>): T;
120
+ export declare function createSecretRedactionStream(secrets: Iterable<string>): SecretRedactionStream;
121
+ //#endregion
58
122
  //#region src/services/profileText/index.d.ts
59
123
  /** Footer status key the cockpit's profile axis reads. */
60
124
  interface SelectItem {
@@ -76,5 +140,5 @@ export declare function profileDescription(profile: AgentProfile): string;
76
140
  export declare function profileSummary(profile: AgentProfile): string;
77
141
  export declare function profileTitle(current?: string): string;
78
142
  //#endregion
79
- export type { ProfileProviderFactory, ProfileRuntime, ProfileRuntimeOptions, ProfileRuntimeSnapshot, ProfileSecretRequest, ProfileSecretResolver };
143
+ export type { ProfileEnvSecretRequest, ProfileProviderFactory, ProfileRuntime, ProfileRuntimeOptions, ProfileRuntimeSnapshot, ProfileSecretRequest, ProfileSecretResolver, ProfileSecrets, ProfileSecretsOptions, SecretRedactionStream };
80
144
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/constants/profileRuntime.ts","../src/services/profileRuntime/type.ts","../src/services/profileRuntime/index.ts","../src/services/profileText/index.ts"],"mappings":";;;qBAAa;;;UCEI;WACN;WACA,cAAc;WACd;WACA,QAAQ;;;UAIF;EACf,cAAc,WAAW,wBAAwB,QAAQ,cAAc;EACvE,kBAAkB;;;KAIR,0BACV,SAAS,2BACT;WAAoB;WAA8B,QAAQ;WAAsB;MAC7E,QAAQ;UAEI;;WAEN;WACA,SAAS;;UAGH;EACf,iBAAiB;;EAEjB,SAAS;;EAET,eAAe,sBAAsB,SAAS,yBAAyB,cAAc;EACrF,cAAc,cAAc,SAAS,uBAAuB;EAC5D,OAAO,uBAAuB;;EAE9B;EACA,WAAW;;UAGI;WACN;;WAEA,cAAc,wBAAwB;;;;wBCmKjC,qBAAqB,SAAS,wBAAwB;;wBAKtD,2BAA2B,SAAS,kBAAkB,SAAS;wBAM/D,sBAAsB,SAAS,UAAU;;YAO7C;IACR,sBAAsB;;;;;;UC5NhB;EACR;EACA;EACA;;qBAGW;;;;;;wBAaG,cAAc,6BAA6B;;wBAM3C,aAAa,UAAU,iBAAiB;wBAQxC,mBAAmB,SAAS;;wBAM5B,eAAe,SAAS;wBAUxB,aAAa"}
1
+ {"version":3,"file":"index.d.mts","names":["_0"],"sources":["../src/constants/profileRuntime.ts","../src/constants/profileSecrets.ts","../src/services/profileRuntime/type.ts","../src/services/profileRuntime/index.ts","../src/services/profileSecrets/type.ts","../src/services/profileSecrets/index.ts","../src/services/secretRedaction/type.ts","../src/services/secretRedaction/index.ts","../src/services/profileText/index.ts"],"mappings":";;;qBAAa;;;qBCCA;;;UCCI;WACN;WACA,cAAc;;WAEd,MAAM,SAAS;WACf;WACA,QAAQ;;;UAIF;EACf,cAAc,WAAW,wBAAwB,QAAQ,cAAc;EACvE,kBAAkB;;;KAIR,0BACV,SAAS,2BACT;WAAoB;WAA8B,QAAQ;WAAsB;MAC7E,QAAQ;UAEI;;WAEN;WACA,SAAS;;UAGH;EACf,iBAAiB;;EAEjB,SAAS;;EAET,eAAe,sBAAsB,SAAS,yBAAyB,cAAc;;EAErF,cAAc,cAAc,SAAS,uBAAuB;;EAE5D,mBAAmB,SAAS,cAAc;EAC1C,OAAO,uBAAuB;;EAE9B;EACA,WAAW;;UAGI;WACN;;WAEA,cAAc,wBAAwB;;WAEtC,WAAW,wBAAwB,SAAS;;;;wBCiLvC,qBAAqB,SAAS,wBAAwB;;wBAKtD,2BAA2B,SAAS,kBAAkB,SAAS;wBAM/D,sBAAsB,SAAS,UAAU;;YAO7C;IACR,sBAAsB;;;;;UClPT;;WAEN;WACA;;WAEA;WACA,SAAS;WACT;;;UAIM;;EAEf,iBAAiB,kBAAkB,SAAS;;EAE5C,WAAW,SAAS,0BAA0B,QAAQ;;UAGvC;;WAEN,cACP,aACA,iBACA,sCACG,wCAAwC,QAAQ;;;;wBCyCvC,qBAAqB,SAAS,wBAAwB;;qBAKzD,8BAA8B,mBAAmB;mBAGzC;EAFnB,YACE,SAAS,SACQ,QAAQ;EAK3B,iBAAiB,kBAAkB,SAAS;EAI5C,WAAW,SAAS,0BAA0B,QAAQ;;;wBAMxC,2BAA2B,QAAQ,kBAAkB,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