@agimon-ai/po-profile 0.0.0-alpha.39 → 0.0.0-alpha.40

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,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_profileText = require("../profileText-BSaTvVwa.cjs");
5
+ const require_profileText = require("../profileText-eSDL6Q5R.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");
@@ -12,18 +12,19 @@ let _agimon_ai_po_core_profileIdentity = require("@agimon-ai/po-core/profileIden
12
12
  //#region src/extensions/(backend)/root.server.ts
13
13
  var root_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ host }) => {
14
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 });
15
+ const sources = require_profileText.createProfileSources();
16
+ const secrets = require_profileText.createProfileSecrets({ readBinding: (cwd, profile, homeDirectory) => require_profileText.findProfile((0, _agimon_ai_po_config_profiles.loadProfiles)(cwd, homeDirectory ?? environment.HOME ?? _agimon_ai_po_core_platform.nodeHost.homeDirectory()), sources, profile).integration });
16
17
  return {
17
18
  value: secrets,
18
- services: [require_profileText.createProfileSecretsPlugin(secrets)]
19
+ services: [require_profileText.createProfileSecretsPlugin(secrets), require_profileText.createProfileSourcesPlugin(sources)]
19
20
  };
20
21
  });
21
22
  //#endregion
22
23
  //#region src/extensions/workspaces/sessions/(backend)/root.server.ts
23
- var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ agent, signal }) => {
24
+ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ agent, signal, context }) => {
24
25
  if (!agent) return { value: void 0 };
25
26
  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());
27
+ const readProfile = (profileName) => require_profileText.findProfile((0, _agimon_ai_po_config_profiles.loadProfiles)(execution.repoRoot, execution.environment.HOME ?? _agimon_ai_po_core_platform.nodeHost.homeDirectory()), require_profileText.readProfileSources(context), profileName);
27
28
  const runtime = require_profileText.createProfileRuntime({
28
29
  profileName: execution.selection.profile,
29
30
  readBinding: (profileName) => readProfile(profileName).integration,
@@ -71,29 +72,30 @@ var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)(({
71
72
  }));
72
73
  //#endregion
73
74
  //#region src/extensions/workspaces/sessions/(backend)/_lib/profileServer.ts
74
- async function readSelectedPersona(execution) {
75
+ const resolveSelected = (execution, sources, name) => require_profileText.findProfile((0, _agimon_ai_po_config_profiles.loadProfiles)(execution.repoRoot, execution.environment?.HOME), sources, name);
76
+ async function readSelectedPersona(execution, sources) {
75
77
  const name = execution.selection.profile;
76
78
  if (!name) return "(no active profile)";
77
- const profile = (0, _agimon_ai_po_config_profiles.resolveProfile)(execution.repoRoot, name, execution.environment?.HOME);
78
- const prompt = (0, _agimon_ai_po_config_profiles.buildPersonaPrompt)(profile.personaRoot, profile.persona);
79
+ const profile = resolveSelected(execution, sources, name);
80
+ const prompt = profile.personaPrompt ?? (0, _agimon_ai_po_config_profiles.buildPersonaPrompt)(profile.personaRoot, profile.persona);
79
81
  if (!prompt) throw new Error(`Profile "${name}" has no readable persona text`);
80
82
  return prompt;
81
83
  }
82
- async function publishSelectedIdentity(execution, profile) {
83
- const identity = (0, _agimon_ai_po_config_profiles.resolveProfile)(execution.repoRoot, profile, execution.environment.HOME).identity;
84
+ async function publishSelectedIdentity(execution, sources, profile) {
85
+ const identity = resolveSelected(execution, sources, profile).identity;
84
86
  await execution.session.appendCustomEntry(_agimon_ai_po_core_profileIdentity.PO_PROFILE_IDENTITY_ENTRY_TYPE, {
85
87
  profile,
86
88
  ...identity?.name === void 0 ? {} : { name: identity.name },
87
89
  ...identity?.icon === void 0 ? {} : { icon: identity.icon }
88
90
  });
89
91
  }
90
- function createProfileServerCommand(host) {
92
+ function createProfileServerCommand(host, sources) {
91
93
  return {
92
94
  name: require_profileText.PROFILE_COMMAND,
93
95
  description: "Show or change the active Po profile.",
94
96
  selectionRecovery: true,
95
97
  async execute(args, execution) {
96
- const profiles = (0, _agimon_ai_po_config_profiles.loadProfiles)(execution.repoRoot, execution.environment.HOME);
98
+ const profiles = require_profileText.mergeProfiles((0, _agimon_ai_po_config_profiles.loadProfiles)(execution.repoRoot, execution.environment.HOME), sources);
97
99
  let requested = args.trim();
98
100
  if (!requested) {
99
101
  const selected = await execution.client.request({
@@ -115,7 +117,7 @@ function createProfileServerCommand(host) {
115
117
  if ((0, _agimon_ai_po_core_headless.isPoHeadlessPromptAdmissionError)(error)) throw new _agimon_ai_po_core_headless.PoSessionSetupError("Profile integration is unavailable. Restore its credential or choose another profile.");
116
118
  throw error;
117
119
  }
118
- await publishSelectedIdentity(execution, requested);
120
+ await publishSelectedIdentity(execution, sources, requested);
119
121
  }
120
122
  };
121
123
  }
@@ -126,16 +128,18 @@ async function assertProfileReady(runtime) {
126
128
  throw new _agimon_ai_po_core_headless.PoHeadlessPromptAdmissionError(error);
127
129
  }
128
130
  }
129
- const profileIdentityHook = {
130
- event: "session_start",
131
- async handle(_event, execution) {
132
- const profile = execution.selection.profile;
133
- if (profile !== void 0) await publishSelectedIdentity(execution, profile);
134
- }
135
- };
131
+ function createProfileIdentityHook(sources) {
132
+ return {
133
+ event: "session_start",
134
+ async handle(_event, execution) {
135
+ const profile = execution.selection.profile;
136
+ if (profile !== void 0) await publishSelectedIdentity(execution, sources, profile);
137
+ }
138
+ };
139
+ }
136
140
  //#endregion
137
141
  //#region src/extensions/workspaces/sessions/(backend)/command/profile.server.ts
138
- var profile_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)(({ agent }) => agent ? createProfileServerCommand(agent) : void 0, { cardinality: "optional" });
142
+ var profile_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)(({ agent, context }) => agent ? createProfileServerCommand(agent, require_profileText.readProfileSources(context)) : void 0, { cardinality: "optional" });
139
143
  //#endregion
140
144
  //#region src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server.ts
141
145
  var beforeAgentStart_server_default = (0, _agimon_ai_po_core_extensionFile.defineHook)(({ root }) => ({ async handle() {
@@ -143,13 +147,16 @@ var beforeAgentStart_server_default = (0, _agimon_ai_po_core_extensionFile.defin
143
147
  } }));
144
148
  //#endregion
145
149
  //#region src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server.ts
146
- var sessionStart_server_default = (0, _agimon_ai_po_core_extensionFile.defineHook)(({ root }) => ({
147
- ...profileIdentityHook,
148
- async handle(event, execution) {
149
- await assertProfileReady(root);
150
- await profileIdentityHook.handle(event, execution);
151
- }
152
- }));
150
+ var sessionStart_server_default = (0, _agimon_ai_po_core_extensionFile.defineHook)(({ root, context }) => {
151
+ const identityHook = createProfileIdentityHook(require_profileText.readProfileSources(context));
152
+ return {
153
+ ...identityHook,
154
+ async handle(event, execution) {
155
+ await assertProfileReady(root);
156
+ await identityHook.handle(event, execution);
157
+ }
158
+ };
159
+ });
153
160
  //#endregion
154
161
  //#region src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server.ts
155
162
  var help_how_to_profile_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
@@ -168,11 +175,11 @@ var help_how_to_profile_server_default = (0, _agimon_ai_po_core_extensionFile.de
168
175
  });
169
176
  //#endregion
170
177
  //#region src/extensions/workspaces/sessions/(backend)/resource/profileConfig.server.ts
171
- var profileConfig_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
178
+ var profileConfig_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)(({ context }) => ({
172
179
  name: "po/profile-config",
173
180
  kind: "context",
174
- read: readSelectedPersona
175
- });
181
+ read: (execution) => readSelectedPersona(execution, require_profileText.readProfileSources(context))
182
+ }));
176
183
  //#endregion
177
184
  //#region generated/server.ts
178
185
  const at = (value, context) => typeof value === "function" ? value(context) : value;
@@ -1 +1 @@
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,QAAQC,4BAAAA,SAAS,cAAc,CAAC;CACxG,MAAM,UAAUC,oBAAAA,qBAAqB;EACnC,aAAa,UAAU,UAAU;EACjC,cAAc,gBAAgB,YAAY,WAAW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1B,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
+ {"version":3,"file":"server.cjs","names":["defineRoot","createProfileSources","createProfileSecrets","findProfile","loadProfiles","nodeHost","createProfileSecretsPlugin","createProfileSourcesPlugin","defineRoot","findProfile","loadProfiles","nodeHost","readProfileSources","createProfileRuntime","PoHeadlessPromptAdmissionError","createProfileRuntimePlugin","runCleanups","defineRoute","findProfile","loadProfiles","buildPersonaPrompt","PO_PROFILE_IDENTITY_ENTRY_TYPE","PROFILE_COMMAND","mergeProfiles","profileTitle","profileItems","isPoHeadlessPromptAdmissionError","PoSessionSetupError","PoHeadlessPromptAdmissionError","defineRoutedContribution","readProfileSources","defineHook","defineHook","readProfileSources","defineResource","packageResourcePath","readPackageResource","defineResource","readProfileSources","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 { loadProfiles } 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';\nimport { createProfileSources, createProfileSourcesPlugin, findProfile } from '../../services/profileSources';\n\nexport default defineRoot(({ host }: PoServerPluginContext) => {\n const environment = Object.freeze({ ...host.context.environment });\n const sources = createProfileSources();\n const secrets = createProfileSecrets({\n readBinding: (cwd, profile, homeDirectory) =>\n findProfile(loadProfiles(cwd, homeDirectory ?? environment.HOME ?? nodeHost.homeDirectory()), sources, profile)\n .integration,\n });\n return {\n value: secrets,\n services: [createProfileSecretsPlugin(secrets), createProfileSourcesPlugin(sources)],\n };\n});\n","import { loadProfiles } 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';\nimport { findProfile, readProfileSources } from '../../../../services/profileSources';\n\nexport default defineRoot(({ agent, signal, context }: PoServerPluginContext) => {\n if (!agent) return { value: undefined };\n const execution = agent.context;\n const readProfile = (profileName: string) =>\n findProfile(\n loadProfiles(execution.repoRoot, execution.environment.HOME ?? nodeHost.homeDirectory()),\n readProfileSources(context),\n profileName,\n );\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 } 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 { findProfile, mergeProfiles } from '../../../../../services/profileSources';\nimport type { ProfileSources } from '../../../../../services/profileSources/type';\nimport { PROFILE_COMMAND, profileItems, profileTitle } from '../../../../../services/profileText';\n\ntype ProfileExecution = {\n readonly repoRoot: string;\n readonly environment?: Readonly<Record<string, string | undefined>>;\n};\n\nconst resolveSelected = (execution: ProfileExecution, sources: ProfileSources | undefined, name: string) =>\n findProfile(loadProfiles(execution.repoRoot, execution.environment?.HOME), sources, name);\n\nexport async function readSelectedPersona(\n execution: ProfileExecution & { readonly selection: { readonly profile?: string } },\n sources?: ProfileSources,\n): Promise<string> {\n const name = execution.selection.profile;\n if (!name) return '(no active profile)';\n const profile = resolveSelected(execution, sources, name);\n const prompt = profile.personaPrompt ?? 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(\n execution: PoHeadlessExecutionContext,\n sources: ProfileSources | undefined,\n profile: string,\n): Promise<void> {\n const identity = resolveSelected(execution, sources, profile).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, sources?: ProfileSources): 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 = mergeProfiles(loadProfiles(execution.repoRoot, execution.environment.HOME), sources);\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, sources, 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 function createProfileIdentityHook(sources?: ProfileSources): PoHeadlessHook<'session_start'> {\n return {\n event: 'session_start',\n async handle(_event, execution) {\n const profile = execution.selection.profile;\n if (profile !== undefined) await publishSelectedIdentity(execution, sources, profile);\n },\n };\n}\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { readProfileSources } from '../../../../../services/profileSources';\nimport { createProfileServerCommand } from '../_lib/profileServer';\nexport default defineRoutedContribution(\n ({ agent, context }: PoServerPluginContext) =>\n agent ? createProfileServerCommand(agent, readProfileSources(context)) : 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 { readProfileSources } from '../../../../../services/profileSources';\nimport { assertProfileReady, createProfileIdentityHook } from '../_lib/profileServer';\n\nexport default defineHook(({ root, context }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => {\n const identityHook = createProfileIdentityHook(readProfileSources(context));\n return {\n ...identityHook,\n async handle(event: Readonly<Record<string, unknown>>, execution: PoHeadlessExecutionContext) {\n await assertProfileReady(root);\n await identityHook.handle(event, execution);\n },\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';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { readProfileSources } from '../../../../../services/profileSources';\nimport { readSelectedPersona } from '../_lib/profileServer';\nexport default defineResource(({ context }: PoServerPluginContext) => ({\n name: 'po/profile-config',\n kind: 'context' as const,\n read: (execution: Parameters<typeof readSelectedPersona>[0]) =>\n readSelectedPersona(execution, readProfileSources(context)),\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 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":";;;;;;;;;;;;AAQA,IAAA,yBAAA,GAAeA,iCAAAA,WAAAA,EAAY,EAAE,WAAkC;CAC7D,MAAM,cAAc,OAAO,OAAO,EAAE,GAAG,KAAK,QAAQ,YAAY,CAAC;CACjE,MAAM,UAAUC,oBAAAA,qBAAqB;CACrC,MAAM,UAAUC,oBAAAA,qBAAqB,EACnC,cAAc,KAAK,SAAS,kBAC1BC,oBAAAA,aAAAA,GAAYC,8BAAAA,aAAAA,CAAa,KAAK,iBAAiB,YAAY,QAAQC,4BAAAA,SAAS,cAAc,CAAC,GAAG,SAAS,OAAO,CAAC,CAC5G,YACP,CAAC;CACD,OAAO;EACL,OAAO;EACP,UAAU,CAACC,oBAAAA,2BAA2B,OAAO,GAAGC,oBAAAA,2BAA2B,OAAO,CAAC;CACrF;AACF,CAAC;;;ACXD,IAAA,uBAAA,GAAeC,i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AI,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,5 +1,5 @@
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
- import { buildPersonaPrompt, loadProfiles, resolveProfile } from "@agimon-ai/po-config/profiles";
1
+ import { _ as createProfileRuntime, c as createProfileSources, d as mergeProfiles, f as readProfileSources, h as createProfileSecretsPlugin, i as profileItems, l as createProfileSourcesPlugin, m as createProfileSecrets, s as profileTitle, t as PROFILE_COMMAND, u as findProfile, v as createProfileRuntimePlugin } from "../profileText-kBfecwbl.mjs";
2
+ import { buildPersonaPrompt, loadProfiles } 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
5
  import { nodeHost } from "@agimon-ai/po-core/platform";
@@ -8,18 +8,19 @@ import { PO_PROFILE_IDENTITY_ENTRY_TYPE } from "@agimon-ai/po-core/profileIdenti
8
8
  //#region src/extensions/(backend)/root.server.ts
9
9
  var root_server_default$1 = defineRoot(({ host }) => {
10
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 });
11
+ const sources = createProfileSources();
12
+ const secrets = createProfileSecrets({ readBinding: (cwd, profile, homeDirectory) => findProfile(loadProfiles(cwd, homeDirectory ?? environment.HOME ?? nodeHost.homeDirectory()), sources, profile).integration });
12
13
  return {
13
14
  value: secrets,
14
- services: [createProfileSecretsPlugin(secrets)]
15
+ services: [createProfileSecretsPlugin(secrets), createProfileSourcesPlugin(sources)]
15
16
  };
16
17
  });
17
18
  //#endregion
18
19
  //#region src/extensions/workspaces/sessions/(backend)/root.server.ts
19
- var root_server_default = defineRoot(({ agent, signal }) => {
20
+ var root_server_default = defineRoot(({ agent, signal, context }) => {
20
21
  if (!agent) return { value: void 0 };
21
22
  const execution = agent.context;
22
- const readProfile = (profileName) => resolveProfile(execution.repoRoot, profileName, execution.environment.HOME ?? nodeHost.homeDirectory());
23
+ const readProfile = (profileName) => findProfile(loadProfiles(execution.repoRoot, execution.environment.HOME ?? nodeHost.homeDirectory()), readProfileSources(context), profileName);
23
24
  const runtime = createProfileRuntime({
24
25
  profileName: execution.selection.profile,
25
26
  readBinding: (profileName) => readProfile(profileName).integration,
@@ -67,29 +68,30 @@ var route_server_default = defineRoute(({ agent }) => ({
67
68
  }));
68
69
  //#endregion
69
70
  //#region src/extensions/workspaces/sessions/(backend)/_lib/profileServer.ts
70
- async function readSelectedPersona(execution) {
71
+ const resolveSelected = (execution, sources, name) => findProfile(loadProfiles(execution.repoRoot, execution.environment?.HOME), sources, name);
72
+ async function readSelectedPersona(execution, sources) {
71
73
  const name = execution.selection.profile;
72
74
  if (!name) return "(no active profile)";
73
- const profile = resolveProfile(execution.repoRoot, name, execution.environment?.HOME);
74
- const prompt = buildPersonaPrompt(profile.personaRoot, profile.persona);
75
+ const profile = resolveSelected(execution, sources, name);
76
+ const prompt = profile.personaPrompt ?? buildPersonaPrompt(profile.personaRoot, profile.persona);
75
77
  if (!prompt) throw new Error(`Profile "${name}" has no readable persona text`);
76
78
  return prompt;
77
79
  }
78
- async function publishSelectedIdentity(execution, profile) {
79
- const identity = resolveProfile(execution.repoRoot, profile, execution.environment.HOME).identity;
80
+ async function publishSelectedIdentity(execution, sources, profile) {
81
+ const identity = resolveSelected(execution, sources, profile).identity;
80
82
  await execution.session.appendCustomEntry(PO_PROFILE_IDENTITY_ENTRY_TYPE, {
81
83
  profile,
82
84
  ...identity?.name === void 0 ? {} : { name: identity.name },
83
85
  ...identity?.icon === void 0 ? {} : { icon: identity.icon }
84
86
  });
85
87
  }
86
- function createProfileServerCommand(host) {
88
+ function createProfileServerCommand(host, sources) {
87
89
  return {
88
90
  name: PROFILE_COMMAND,
89
91
  description: "Show or change the active Po profile.",
90
92
  selectionRecovery: true,
91
93
  async execute(args, execution) {
92
- const profiles = loadProfiles(execution.repoRoot, execution.environment.HOME);
94
+ const profiles = mergeProfiles(loadProfiles(execution.repoRoot, execution.environment.HOME), sources);
93
95
  let requested = args.trim();
94
96
  if (!requested) {
95
97
  const selected = await execution.client.request({
@@ -111,7 +113,7 @@ function createProfileServerCommand(host) {
111
113
  if (isPoHeadlessPromptAdmissionError(error)) throw new PoSessionSetupError("Profile integration is unavailable. Restore its credential or choose another profile.");
112
114
  throw error;
113
115
  }
114
- await publishSelectedIdentity(execution, requested);
116
+ await publishSelectedIdentity(execution, sources, requested);
115
117
  }
116
118
  };
117
119
  }
@@ -122,16 +124,18 @@ async function assertProfileReady(runtime) {
122
124
  throw new PoHeadlessPromptAdmissionError(error);
123
125
  }
124
126
  }
125
- const profileIdentityHook = {
126
- event: "session_start",
127
- async handle(_event, execution) {
128
- const profile = execution.selection.profile;
129
- if (profile !== void 0) await publishSelectedIdentity(execution, profile);
130
- }
131
- };
127
+ function createProfileIdentityHook(sources) {
128
+ return {
129
+ event: "session_start",
130
+ async handle(_event, execution) {
131
+ const profile = execution.selection.profile;
132
+ if (profile !== void 0) await publishSelectedIdentity(execution, sources, profile);
133
+ }
134
+ };
135
+ }
132
136
  //#endregion
133
137
  //#region src/extensions/workspaces/sessions/(backend)/command/profile.server.ts
134
- var profile_server_default = defineRoutedContribution(({ agent }) => agent ? createProfileServerCommand(agent) : void 0, { cardinality: "optional" });
138
+ var profile_server_default = defineRoutedContribution(({ agent, context }) => agent ? createProfileServerCommand(agent, readProfileSources(context)) : void 0, { cardinality: "optional" });
135
139
  //#endregion
136
140
  //#region src/extensions/workspaces/sessions/(backend)/hook/beforeAgentStart.server.ts
137
141
  var beforeAgentStart_server_default = defineHook(({ root }) => ({ async handle() {
@@ -139,13 +143,16 @@ var beforeAgentStart_server_default = defineHook(({ root }) => ({ async handle()
139
143
  } }));
140
144
  //#endregion
141
145
  //#region src/extensions/workspaces/sessions/(backend)/hook/sessionStart.server.ts
142
- var sessionStart_server_default = defineHook(({ root }) => ({
143
- ...profileIdentityHook,
144
- async handle(event, execution) {
145
- await assertProfileReady(root);
146
- await profileIdentityHook.handle(event, execution);
147
- }
148
- }));
146
+ var sessionStart_server_default = defineHook(({ root, context }) => {
147
+ const identityHook = createProfileIdentityHook(readProfileSources(context));
148
+ return {
149
+ ...identityHook,
150
+ async handle(event, execution) {
151
+ await assertProfileReady(root);
152
+ await identityHook.handle(event, execution);
153
+ }
154
+ };
155
+ });
149
156
  //#endregion
150
157
  //#region src/extensions/workspaces/sessions/(backend)/resource/help-how-to-profile.server.ts
151
158
  var help_how_to_profile_server_default = defineResource({
@@ -164,11 +171,11 @@ var help_how_to_profile_server_default = defineResource({
164
171
  });
165
172
  //#endregion
166
173
  //#region src/extensions/workspaces/sessions/(backend)/resource/profileConfig.server.ts
167
- var profileConfig_server_default = defineResource({
174
+ var profileConfig_server_default = defineResource(({ context }) => ({
168
175
  name: "po/profile-config",
169
176
  kind: "context",
170
- read: readSelectedPersona
171
- });
177
+ read: (execution) => readSelectedPersona(execution, readProfileSources(context))
178
+ }));
172
179
  //#endregion
173
180
  //#region generated/server.ts
174
181
  const at = (value, context) => typeof value === "function" ? value(context) : value;
@@ -1 +1 @@
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,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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"}
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 { loadProfiles } 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';\nimport { createProfileSources, createProfileSourcesPlugin, findProfile } from '../../services/profileSources';\n\nexport default defineRoot(({ host }: PoServerPluginContext) => {\n const environment = Object.freeze({ ...host.context.environment });\n const sources = createProfileSources();\n const secrets = createProfileSecrets({\n readBinding: (cwd, profile, homeDirectory) =>\n findProfile(loadProfiles(cwd, homeDirectory ?? environment.HOME ?? nodeHost.homeDirectory()), sources, profile)\n .integration,\n });\n return {\n value: secrets,\n services: [createProfileSecretsPlugin(secrets), createProfileSourcesPlugin(sources)],\n };\n});\n","import { loadProfiles } 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';\nimport { findProfile, readProfileSources } from '../../../../services/profileSources';\n\nexport default defineRoot(({ agent, signal, context }: PoServerPluginContext) => {\n if (!agent) return { value: undefined };\n const execution = agent.context;\n const readProfile = (profileName: string) =>\n findProfile(\n loadProfiles(execution.repoRoot, execution.environment.HOME ?? nodeHost.homeDirectory()),\n readProfileSources(context),\n profileName,\n );\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 } 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 { findProfile, mergeProfiles } from '../../../../../services/profileSources';\nimport type { ProfileSources } from '../../../../../services/profileSources/type';\nimport { PROFILE_COMMAND, profileItems, profileTitle } from '../../../../../services/profileText';\n\ntype ProfileExecution = {\n readonly repoRoot: string;\n readonly environment?: Readonly<Record<string, string | undefined>>;\n};\n\nconst resolveSelected = (execution: ProfileExecution, sources: ProfileSources | undefined, name: string) =>\n findProfile(loadProfiles(execution.repoRoot, execution.environment?.HOME), sources, name);\n\nexport async function readSelectedPersona(\n execution: ProfileExecution & { readonly selection: { readonly profile?: string } },\n sources?: ProfileSources,\n): Promise<string> {\n const name = execution.selection.profile;\n if (!name) return '(no active profile)';\n const profile = resolveSelected(execution, sources, name);\n const prompt = profile.personaPrompt ?? 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(\n execution: PoHeadlessExecutionContext,\n sources: ProfileSources | undefined,\n profile: string,\n): Promise<void> {\n const identity = resolveSelected(execution, sources, profile).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, sources?: ProfileSources): 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 = mergeProfiles(loadProfiles(execution.repoRoot, execution.environment.HOME), sources);\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, sources, 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 function createProfileIdentityHook(sources?: ProfileSources): PoHeadlessHook<'session_start'> {\n return {\n event: 'session_start',\n async handle(_event, execution) {\n const profile = execution.selection.profile;\n if (profile !== undefined) await publishSelectedIdentity(execution, sources, profile);\n },\n };\n}\n","import { defineRoutedContribution } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { readProfileSources } from '../../../../../services/profileSources';\nimport { createProfileServerCommand } from '../_lib/profileServer';\nexport default defineRoutedContribution(\n ({ agent, context }: PoServerPluginContext) =>\n agent ? createProfileServerCommand(agent, readProfileSources(context)) : 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 { readProfileSources } from '../../../../../services/profileSources';\nimport { assertProfileReady, createProfileIdentityHook } from '../_lib/profileServer';\n\nexport default defineHook(({ root, context }: WithRoot<PoServerPluginContext, ProfileRuntime | undefined>) => {\n const identityHook = createProfileIdentityHook(readProfileSources(context));\n return {\n ...identityHook,\n async handle(event: Readonly<Record<string, unknown>>, execution: PoHeadlessExecutionContext) {\n await assertProfileReady(root);\n await identityHook.handle(event, execution);\n },\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';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { readProfileSources } from '../../../../../services/profileSources';\nimport { readSelectedPersona } from '../_lib/profileServer';\nexport default defineResource(({ context }: PoServerPluginContext) => ({\n name: 'po/profile-config',\n kind: 'context' as const,\n read: (execution: Parameters<typeof readSelectedPersona>[0]) =>\n readSelectedPersona(execution, readProfileSources(context)),\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 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":";;;;;;;;AAQA,IAAA,wBAAe,YAAY,EAAE,WAAkC;CAC7D,MAAM,cAAc,OAAO,OAAO,EAAE,GAAG,KAAK,QAAQ,YAAY,CAAC;CACjE,MAAM,UAAU,qBAAqB;CACrC,MAAM,UAAU,qBAAqB,EACnC,cAAc,KAAK,SAAS,kBAC1B,YAAY,aAAa,KAAK,iBAAiB,YAAY,QAAQ,SAAS,cAAc,CAAC,GAAG,SAAS,OAAO,CAAC,CAC5G,YACP,CAAC;CACD,OAAO;EACL,OAAO;EACP,UAAU,CAAC,2BAA2B,OAAO,GAAG,2BAA2B,OAAO,CAAC;CACrF;AACF,CAAC;;;ACXD,IAAA,sBAAe,YAAY,EAAE,OAAO,QAAQ,cAAqC;CAC/E,IAAI,CAAC,OAAO,OAAO,EAAE,OAAO,KAAA,EAAU;CACtC,MAAM,YAAY,MAAM;CACxB,MAAM,eAAe,gBACnB,YACE,aAAa,UAAU,UAAU,UAAU,YAAY,QAAQ,SAAS,cAAc,CAAC,GACvF,mBAAmB,OAAO,GAC1B,WACF;CACF,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,UAA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C,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,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_profileText = require("./profileText-BSaTvVwa.cjs");
2
+ const require_profileText = require("./profileText-eSDL6Q5R.cjs");
3
3
  //#region src/services/secretRedaction/index.ts
4
4
  const REDACTED = "[redacted]";
5
5
  /** Raw, JSON-escaped and URL-encoded forms of every non-empty value. */
@@ -66,18 +66,22 @@ function createSecretRedactionStream(secrets) {
66
66
  //#endregion
67
67
  exports.PROFILE_RUNTIME_SERVICE = require_profileText.PROFILE_RUNTIME_SERVICE;
68
68
  exports.PROFILE_SECRETS_SERVICE = require_profileText.PROFILE_SECRETS_SERVICE;
69
+ exports.PROFILE_SOURCES_SERVICE = require_profileText.PROFILE_SOURCES_SERVICE;
69
70
  exports.PROFILE_STATUS_KEY = require_profileText.PROFILE_STATUS_KEY;
70
71
  exports.ProfileSecretsService = require_profileText.ProfileSecretsService;
71
72
  exports.createProfileRuntime = require_profileText.createProfileRuntime;
72
73
  exports.createProfileRuntimePlugin = require_profileText.createProfileRuntimePlugin;
73
74
  exports.createProfileSecrets = require_profileText.createProfileSecrets;
74
75
  exports.createProfileSecretsPlugin = require_profileText.createProfileSecretsPlugin;
76
+ exports.createProfileSources = require_profileText.createProfileSources;
77
+ exports.createProfileSourcesPlugin = require_profileText.createProfileSourcesPlugin;
75
78
  exports.createSecretRedactionStream = createSecretRedactionStream;
76
79
  exports.profileDescription = require_profileText.profileDescription;
77
80
  exports.profileItems = require_profileText.profileItems;
78
81
  exports.profileStatus = require_profileText.profileStatus;
79
82
  exports.profileSummary = require_profileText.profileSummary;
80
83
  exports.profileTitle = require_profileText.profileTitle;
84
+ exports.readProfileSources = require_profileText.readProfileSources;
81
85
  exports.redactSecrets = redactSecrets;
82
86
  exports.requireProfileRuntime = require_profileText.requireProfileRuntime;
83
87
  exports.requireProfileSecrets = require_profileText.requireProfileSecrets;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AgentProfile, ProfileIntegrationBinding, ProfileSecretReference } from "@agimon-ai/po-config/profiles";
1
+ import { AgentProfile, InlineProfileInput, ProfileIntegrationBinding, ProfileSecretReference } from "@agimon-ai/po-config/profiles";
2
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";
@@ -6,6 +6,9 @@ export declare const PROFILE_RUNTIME_SERVICE = "po/profile-runtime";
6
6
  //#region src/constants/profileSecrets.d.ts
7
7
  export declare const PROFILE_SECRETS_SERVICE = "po/profile-secrets";
8
8
  //#endregion
9
+ //#region src/constants/profileSources.d.ts
10
+ export declare const PROFILE_SOURCES_SERVICE = "po/profile-sources";
11
+ //#endregion
9
12
  //#region src/services/profileRuntime/type.d.ts
10
13
  interface ProfileRuntimeSnapshot {
11
14
  readonly profileName?: string;
@@ -105,6 +108,43 @@ declare module '@deepseek-ai/cordis' {
105
108
  }
106
109
  }
107
110
  //#endregion
111
+ //#region src/services/profileSources/type.d.ts
112
+ /** Profiles a plugin holds in memory. `list` runs on every catalog read, so it returns cached values. */
113
+ interface ProfileSource {
114
+ list(): readonly InlineProfileInput[];
115
+ }
116
+ /** A contributed profile. Its persona text lives in `personaPrompt` and is never read from disk. */
117
+ type ContributedProfile = AgentProfile & {
118
+ readonly personaPrompt: string;
119
+ };
120
+ interface ProfileSources {
121
+ /** Adds a source under a unique id; the returned function removes it. */
122
+ register(id: string, source: ProfileSource): () => void;
123
+ /**
124
+ * Valid contributed profiles, sorted by name. An invalid definition or a failing
125
+ * source is skipped, and a name an earlier source already holds keeps the earlier one.
126
+ */
127
+ list(): ContributedProfile[];
128
+ }
129
+ //#endregion
130
+ //#region src/services/profileSources/index.d.ts
131
+ export declare function createProfileSources(): ProfileSources;
132
+ /** Profiles plugins hold in memory, merged into the session catalog. Optional: absent means files only. */
133
+ declare class ProfileSourcesService extends Service implements ProfileSources {
134
+ private readonly source;
135
+ constructor(context: Context, source: ProfileSources);
136
+ register(id: string, source: ProfileSource): () => void;
137
+ list(): ContributedProfile[];
138
+ }
139
+ /** Include in the extension services array. The helper owns the child fiber. */
140
+ export declare function createProfileSourcesPlugin(source: ProfileSources): (context: Context) => void;
141
+ export declare function readProfileSources(context: Context): ProfileSources | undefined;
142
+ declare module '@deepseek-ai/cordis' {
143
+ interface Context {
144
+ 'po/profile-sources': ProfileSourcesService;
145
+ }
146
+ }
147
+ //#endregion
108
148
  //#region src/services/secretRedaction/type.d.ts
109
149
  /** Redacts chunked text without emitting a fragment of a secret split across chunks. */
110
150
  interface SecretRedactionStream {
@@ -140,5 +180,5 @@ export declare function profileDescription(profile: AgentProfile): string;
140
180
  export declare function profileSummary(profile: AgentProfile): string;
141
181
  export declare function profileTitle(current?: string): string;
142
182
  //#endregion
143
- export type { ProfileEnvSecretRequest, ProfileProviderFactory, ProfileRuntime, ProfileRuntimeOptions, ProfileRuntimeSnapshot, ProfileSecretRequest, ProfileSecretResolver, ProfileSecrets, ProfileSecretsOptions, SecretRedactionStream };
183
+ export type { ContributedProfile, ProfileEnvSecretRequest, ProfileProviderFactory, ProfileRuntime, ProfileRuntimeOptions, ProfileRuntimeSnapshot, ProfileSecretRequest, ProfileSecretResolver, ProfileSecrets, ProfileSecretsOptions, ProfileSource, ProfileSources, SecretRedactionStream };
144
184
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
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,SAAS;wBAM9D,sBAAsB,SAAS,UAAU;;YAO7C;IACR,sBAAsB;;;;;;UCxGT;;EAEf,MAAM;;EAEN;;;;;wBC+Cc,cAAc,GAAG,OAAO,GAAG,SAAS,mBAAmB;wBAIvD,4BAA4B,SAAS,mBAAmB;;;;UCpD9D;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","_0"],"sources":["../src/constants/profileRuntime.ts","../src/constants/profileSecrets.ts","../src/constants/profileSources.ts","../src/services/profileRuntime/type.ts","../src/services/profileRuntime/index.ts","../src/services/profileSecrets/type.ts","../src/services/profileSecrets/index.ts","../src/services/profileSources/type.ts","../src/services/profileSources/index.ts","../src/services/secretRedaction/type.ts","../src/services/secretRedaction/index.ts","../src/services/profileText/index.ts"],"mappings":";;;qBAAa;;;qBCCA;;;qBCAA;;;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,SAAS;wBAM9D,sBAAsB,SAAS,UAAU;;YAO7C;IACR,sBAAsB;;;;;;UCvGT;EACf,iBAAiB;;;KAIP,qBAAqB;WAA0B;;UAE1C;;EAEf,SAAS,YAAY,QAAQ;;;;;EAK7B,QAAQ;;;;wBCwBM,wBAAwB;;cAuB3B,8BAA8B,mBAAmB;mBAGzC;EAFnB,YACE,SAAS,SACQ,QAAQ;EAK3B,SAAS,YAAY,QAAQ;EAI7B,QAAQ;;;wBAMM,2BAA2B,QAAQ,kBAAkB,SAAS;wBAM9D,mBAAmB,SAAS,UAAU;;YAK1C;IACR,sBAAsB;;;;;;UC5FT;;EAEf,MAAM;;EAEN;;;;;wBC+Cc,cAAc,GAAG,OAAO,GAAG,SAAS,mBAAmB;wBAIvD,4BAA4B,SAAS,mBAAmB;;;;UCpD9D;EACR;EACA;EACA;;qBAGW;;;;;;wBAaG,cAAc,6BAA6B;;wBAM3C,aAAa,UAAU,iBAAiB;wBAQxC,mBAAmB,SAAS;;wBAM5B,eAAe,SAAS;wBAUxB,aAAa"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as profileStatus, c as ProfileSecretsService, d as requireProfileSecrets, f as createProfileRuntime, g as PROFILE_RUNTIME_SERVICE, h as PROFILE_SECRETS_SERVICE, i as profileItems, l as createProfileSecrets, m as requireProfileRuntime, n as PROFILE_STATUS_KEY, o as profileSummary, p as createProfileRuntimePlugin, r as profileDescription, s as profileTitle, u as createProfileSecretsPlugin } from "./profileText-BSQET_iz.mjs";
1
+ import { S as PROFILE_RUNTIME_SERVICE, _ as createProfileRuntime, a as profileStatus, b as PROFILE_SOURCES_SERVICE, c as createProfileSources, f as readProfileSources, g as requireProfileSecrets, h as createProfileSecretsPlugin, i as profileItems, l as createProfileSourcesPlugin, m as createProfileSecrets, n as PROFILE_STATUS_KEY, o as profileSummary, p as ProfileSecretsService, r as profileDescription, s as profileTitle, v as createProfileRuntimePlugin, x as PROFILE_SECRETS_SERVICE, y as requireProfileRuntime } from "./profileText-kBfecwbl.mjs";
2
2
  //#region src/services/secretRedaction/index.ts
3
3
  const REDACTED = "[redacted]";
4
4
  /** Raw, JSON-escaped and URL-encoded forms of every non-empty value. */
@@ -63,6 +63,6 @@ function createSecretRedactionStream(secrets) {
63
63
  };
64
64
  }
65
65
  //#endregion
66
- export { PROFILE_RUNTIME_SERVICE, PROFILE_SECRETS_SERVICE, PROFILE_STATUS_KEY, ProfileSecretsService, createProfileRuntime, createProfileRuntimePlugin, createProfileSecrets, createProfileSecretsPlugin, createSecretRedactionStream, profileDescription, profileItems, profileStatus, profileSummary, profileTitle, redactSecrets, requireProfileRuntime, requireProfileSecrets };
66
+ export { PROFILE_RUNTIME_SERVICE, PROFILE_SECRETS_SERVICE, PROFILE_SOURCES_SERVICE, PROFILE_STATUS_KEY, ProfileSecretsService, createProfileRuntime, createProfileRuntimePlugin, createProfileSecrets, createProfileSecretsPlugin, createProfileSources, createProfileSourcesPlugin, createSecretRedactionStream, profileDescription, profileItems, profileStatus, profileSummary, profileTitle, readProfileSources, redactSecrets, requireProfileRuntime, requireProfileSecrets };
67
67
 
68
68
  //# sourceMappingURL=index.mjs.map
@@ -6,6 +6,9 @@ const PROFILE_RUNTIME_SERVICE = "po/profile-runtime";
6
6
  //#region src/constants/profileSecrets.ts
7
7
  const PROFILE_SECRETS_SERVICE = "po/profile-secrets";
8
8
  //#endregion
9
+ //#region src/constants/profileSources.ts
10
+ const PROFILE_SOURCES_SERVICE = "po/profile-sources";
11
+ //#endregion
9
12
  //#region src/services/profileRuntime/index.ts
10
13
  const UNAVAILABLE$1 = "Profile integration provider is unavailable";
11
14
  const INVALIDATED = "Profile operation was invalidated";
@@ -291,6 +294,77 @@ function requireProfileSecrets(context) {
291
294
  return service;
292
295
  }
293
296
  //#endregion
297
+ //#region src/services/profileSources/index.ts
298
+ var HostProfileSources = class {
299
+ sources = /* @__PURE__ */ new Map();
300
+ register(id, source) {
301
+ if (this.sources.has(id)) throw new Error("Profile source is already registered");
302
+ this.sources.set(id, source);
303
+ return () => {
304
+ if (this.sources.get(id) === source) this.sources.delete(id);
305
+ };
306
+ }
307
+ list() {
308
+ const byName = /* @__PURE__ */ new Map();
309
+ for (const source of this.sources.values()) {
310
+ let inputs;
311
+ try {
312
+ inputs = source.list();
313
+ } catch {
314
+ continue;
315
+ }
316
+ for (const input of inputs) {
317
+ if (byName.has(input.name)) continue;
318
+ try {
319
+ const profile = (0, _agimon_ai_po_config_profiles.inlineProfile)(input);
320
+ if (profile.personaPrompt) byName.set(profile.name, {
321
+ ...profile,
322
+ personaPrompt: profile.personaPrompt
323
+ });
324
+ } catch {}
325
+ }
326
+ }
327
+ return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
328
+ }
329
+ };
330
+ function createProfileSources() {
331
+ return new HostProfileSources();
332
+ }
333
+ /** File profiles win; a contributed profile only fills a name the file catalog does not hold. */
334
+ function mergeProfiles(files, sources) {
335
+ const names = new Set(files.map(({ name }) => name));
336
+ const contributed = (sources?.list() ?? []).filter(({ name }) => !names.has(name));
337
+ return [...files, ...contributed].sort((left, right) => left.name.localeCompare(right.name));
338
+ }
339
+ function findProfile(files, sources, name) {
340
+ const profile = files.find((candidate) => candidate.name === name) ?? sources?.list().find((candidate) => candidate.name === name);
341
+ if (!profile) throw new Error(`Unknown profile: ${name}`);
342
+ return profile;
343
+ }
344
+ /** Profiles plugins hold in memory, merged into the session catalog. Optional: absent means files only. */
345
+ var ProfileSourcesService = class extends _deepseek_ai_cordis.Service {
346
+ source;
347
+ constructor(context, source) {
348
+ super(context, PROFILE_SOURCES_SERVICE);
349
+ this.source = source;
350
+ }
351
+ register(id, source) {
352
+ return this.source.register(id, source);
353
+ }
354
+ list() {
355
+ return this.source.list();
356
+ }
357
+ };
358
+ /** Include in the extension services array. The helper owns the child fiber. */
359
+ function createProfileSourcesPlugin(source) {
360
+ return (context) => {
361
+ new ProfileSourcesService(context, source);
362
+ };
363
+ }
364
+ function readProfileSources(context) {
365
+ return context.get(PROFILE_SOURCES_SERVICE);
366
+ }
367
+ //#endregion
294
368
  //#region src/services/profileText/index.ts
295
369
  const NONE = "(none)";
296
370
  const PROFILE_STATUS_KEY = "po-profile";
@@ -349,6 +423,12 @@ Object.defineProperty(exports, "PROFILE_SECRETS_SERVICE", {
349
423
  return PROFILE_SECRETS_SERVICE;
350
424
  }
351
425
  });
426
+ Object.defineProperty(exports, "PROFILE_SOURCES_SERVICE", {
427
+ enumerable: true,
428
+ get: function() {
429
+ return PROFILE_SOURCES_SERVICE;
430
+ }
431
+ });
352
432
  Object.defineProperty(exports, "PROFILE_STATUS_KEY", {
353
433
  enumerable: true,
354
434
  get: function() {
@@ -385,6 +465,30 @@ Object.defineProperty(exports, "createProfileSecretsPlugin", {
385
465
  return createProfileSecretsPlugin;
386
466
  }
387
467
  });
468
+ Object.defineProperty(exports, "createProfileSources", {
469
+ enumerable: true,
470
+ get: function() {
471
+ return createProfileSources;
472
+ }
473
+ });
474
+ Object.defineProperty(exports, "createProfileSourcesPlugin", {
475
+ enumerable: true,
476
+ get: function() {
477
+ return createProfileSourcesPlugin;
478
+ }
479
+ });
480
+ Object.defineProperty(exports, "findProfile", {
481
+ enumerable: true,
482
+ get: function() {
483
+ return findProfile;
484
+ }
485
+ });
486
+ Object.defineProperty(exports, "mergeProfiles", {
487
+ enumerable: true,
488
+ get: function() {
489
+ return mergeProfiles;
490
+ }
491
+ });
388
492
  Object.defineProperty(exports, "profileDescription", {
389
493
  enumerable: true,
390
494
  get: function() {
@@ -415,6 +519,12 @@ Object.defineProperty(exports, "profileTitle", {
415
519
  return profileTitle;
416
520
  }
417
521
  });
522
+ Object.defineProperty(exports, "readProfileSources", {
523
+ enumerable: true,
524
+ get: function() {
525
+ return readProfileSources;
526
+ }
527
+ });
418
528
  Object.defineProperty(exports, "requireProfileRuntime", {
419
529
  enumerable: true,
420
530
  get: function() {
@@ -428,4 +538,4 @@ Object.defineProperty(exports, "requireProfileSecrets", {
428
538
  }
429
539
  });
430
540
 
431
- //# sourceMappingURL=profileText-BSaTvVwa.cjs.map
541
+ //# sourceMappingURL=profileText-eSDL6Q5R.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileText-eSDL6Q5R.cjs","names":["UNAVAILABLE","parseProfileBinding","Service","inlineProfile","Service"],"sources":["../src/constants/profileRuntime.ts","../src/constants/profileSecrets.ts","../src/constants/profileSources.ts","../src/services/profileRuntime/index.ts","../src/services/profileSecrets/index.ts","../src/services/profileSources/index.ts","../src/services/profileText/index.ts"],"sourcesContent":["export const PROFILE_RUNTIME_SERVICE = 'po/profile-runtime';\n","// @scaffold-generated\nexport const PROFILE_SECRETS_SERVICE = 'po/profile-secrets';\n","// @scaffold-generated\nexport const PROFILE_SOURCES_SERVICE = 'po/profile-sources';\n","import { parseProfileBinding, type ProfileSecretReference } from '@agimon-ai/po-config/profiles';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { PROFILE_RUNTIME_SERVICE } from '../../constants/profileRuntime';\nimport type {\n ProfileProviderFactory,\n ProfileRuntime,\n ProfileRuntimeOptions,\n ProfileRuntimeSnapshot,\n ProfileSecretRequest,\n ProfileSecretResolver,\n} from './type';\n\nconst UNAVAILABLE = 'Profile integration provider is unavailable';\nconst INVALIDATED = 'Profile operation was invalidated';\n\n/** A single selected profile and provider, owned by one session, not a provider registry. */\nclass SessionProfileRuntime implements ProfileRuntime {\n private controller = new AbortController();\n private snapshot: ProfileRuntimeSnapshot;\n private provider?: { name: string; factory: ProfileProviderFactory };\n private connection?: ProfileSecretResolver;\n private transition: Promise<void> = Promise.resolve();\n private retirement: Promise<void> = Promise.resolve();\n private readonly pending = new Set<Promise<void>>();\n private initializing = false;\n private disposed = false;\n private disposal?: Promise<void>;\n\n constructor(private readonly options: ProfileRuntimeOptions) {\n this.snapshot = this.capture(options.profileName, 1);\n }\n\n private capture(profileName: string | undefined, generation: number): ProfileRuntimeSnapshot {\n const binding = profileName === undefined ? undefined : this.options.readBinding(profileName);\n const env = profileName === undefined ? undefined : this.options.readEnv?.(profileName);\n return Object.freeze({\n ...(profileName === undefined ? {} : { profileName }),\n ...(binding === undefined ? {} : { integration: parseProfileBinding(binding) }),\n ...(env === undefined ? {} : { env: Object.freeze({ ...env }) }),\n generation,\n signal: this.controller.signal,\n });\n }\n\n readSelection(): ProfileRuntimeSnapshot {\n return this.snapshot;\n }\n\n invalidate(): void {\n this.controller.abort();\n const connection = this.connection;\n this.connection = undefined;\n if (connection) {\n this.retirement = this.retirement.then(async () => {\n try {\n await connection.dispose();\n } catch {\n throw new Error('Profile provider disposal failed');\n }\n });\n void this.track(this.retirement);\n }\n }\n\n private track(work: Promise<void>): Promise<void> {\n this.pending.add(work);\n // Keep rejection observable through ready/dispose while preventing an unhandled\n // rejection when selection invalidates an initialization before its owner awaits it.\n void work.then(\n () => this.pending.delete(work),\n () => this.pending.delete(work),\n );\n return work;\n }\n\n private initialize(): Promise<void> {\n const snapshot = this.snapshot;\n const provider = this.provider;\n this.initializing = Boolean(snapshot.integration && provider);\n const work = (async () => {\n await this.retirement;\n if (snapshot.signal.aborted) return;\n if (!snapshot.integration || !provider) return;\n if (snapshot.integration.provider !== provider.name) throw new Error(UNAVAILABLE);\n let connection: ProfileSecretResolver;\n try {\n connection = await provider.factory(snapshot.integration, {\n profileName: snapshot.profileName!,\n generation: snapshot.generation,\n signal: snapshot.signal,\n });\n } catch {\n // A retired factory commonly rejects on abort. That cannot remove the\n // provider attachment or poison the replacement generation.\n if (snapshot.signal.aborted) return;\n throw new Error('Profile provider initialization failed');\n }\n if (snapshot.signal.aborted || this.snapshot !== snapshot || this.disposed) {\n try {\n await connection.dispose();\n } catch {\n throw new Error('Profile provider disposal failed');\n }\n return;\n }\n this.connection = connection;\n })();\n this.transition = this.track(\n work.finally(() => {\n if (this.snapshot === snapshot) this.initializing = false;\n }),\n );\n return this.transition;\n }\n\n async select(profileName?: string): Promise<void> {\n if (this.disposed) throw new Error(INVALIDATED);\n if (\n this.snapshot.profileName === profileName &&\n !this.snapshot.signal.aborted &&\n (!this.snapshot.integration || !this.provider || this.connection || this.initializing)\n )\n return;\n this.invalidate();\n this.controller = new AbortController();\n // If reading/validation fails, leave the old generation aborted, never usable.\n this.snapshot = this.capture(profileName, this.snapshot.generation + 1);\n await this.initialize();\n }\n\n async ready(): Promise<void> {\n const snapshot = this.snapshot;\n await this.transition;\n if (this.disposed || snapshot.signal.aborted || this.snapshot !== snapshot) throw new Error(INVALIDATED);\n if (snapshot.integration && !this.connection) throw new Error(UNAVAILABLE);\n }\n\n async attachProvider(providerName: string, factory: ProfileProviderFactory): Promise<() => Promise<void>> {\n if (this.disposed || this.snapshot.signal.aborted) throw new Error(INVALIDATED);\n if (this.provider) throw new Error('Profile provider is already attached');\n if (this.snapshot.integration && this.snapshot.integration.provider !== providerName) throw new Error(UNAVAILABLE);\n const provider = { name: providerName, factory };\n this.provider = provider;\n try {\n await this.initialize();\n await this.ready();\n if (this.disposed || this.provider !== provider) throw new Error(INVALIDATED);\n } catch {\n if (this.provider === provider) this.provider = undefined;\n this.invalidate();\n throw new Error('Profile provider initialization failed');\n }\n let detached = false;\n return async () => {\n if (detached || this.provider !== provider) return;\n detached = true;\n this.invalidate();\n this.provider = undefined;\n this.controller = new AbortController();\n this.snapshot = Object.freeze({\n ...this.snapshot,\n generation: this.snapshot.generation + 1,\n signal: this.controller.signal,\n });\n await this.retirement;\n };\n }\n\n resolveSecret(name: string, request: ProfileSecretRequest): Promise<string> {\n return this.resolveReference(name, request.signal, (reference) => {\n if (!reference.purposes.includes('browser')) throw new Error('Profile secret alias is unavailable');\n if (!reference.allowedOrigins.includes(request.origin)) throw new Error('Profile secret origin is not allowed');\n });\n }\n\n resolveProxySecret(signal?: AbortSignal): Promise<string> {\n const name = this.snapshot.integration?.browser?.proxySecret;\n if (name === undefined) return Promise.reject(new Error('Profile proxy is not configured'));\n return this.resolveReference(name, signal, (reference) => {\n if (!reference.purposes.includes('proxy')) throw new Error('Profile secret alias is unavailable');\n });\n }\n\n private async resolveReference(\n name: string,\n requestSignal: AbortSignal | undefined,\n authorize: (reference: ProfileSecretReference) => void,\n ): Promise<string> {\n // Do not await ready here: a provider factory invoking this callback would\n // otherwise wait for itself. Browser creation may retain, but not invoke it.\n if (this.initializing) throw new Error('Profile secrets are unavailable during provider initialization');\n await this.ready();\n const snapshot = this.snapshot;\n const connection = this.connection;\n const reference = snapshot.integration?.secrets[name];\n if (!connection || !reference || !Object.hasOwn(snapshot.integration!.secrets, name)) {\n throw new Error('Profile secret alias is unavailable');\n }\n authorize(reference);\n const signal = requestSignal ? AbortSignal.any([snapshot.signal, requestSignal]) : snapshot.signal;\n if (signal.aborted) throw new Error(INVALIDATED);\n let value: string;\n try {\n value = await connection.resolveSecret(reference, signal);\n } catch {\n // Provider failures must not leak API responses, credential fields or secrets.\n throw new Error('Profile secret resolution failed');\n }\n if (signal.aborted || this.snapshot !== snapshot || this.connection !== connection) throw new Error(INVALIDATED);\n if (typeof value !== 'string' || value.length === 0) throw new Error('Profile secret field is unavailable');\n return value;\n }\n\n dispose(): Promise<void> {\n if (this.disposal) return this.disposal;\n this.disposed = true;\n this.invalidate();\n this.provider = undefined;\n this.disposal = (async () => {\n const results = await Promise.allSettled([...this.pending, this.retirement]);\n if (results.some((result) => result.status === 'rejected')) throw new Error('Profile runtime disposal failed');\n })();\n return this.disposal;\n }\n}\n\nexport function createProfileRuntime(options: ProfileRuntimeOptions): ProfileRuntime {\n return new SessionProfileRuntime(options);\n}\n\n/** Mounted in the scoped root services array, before dependent integration tools. */\nexport function createProfileRuntimePlugin(runtime: ProfileRuntime): (context: Context) => void {\n return (context) => {\n context.provide(PROFILE_RUNTIME_SERVICE, runtime);\n };\n}\n\nexport function requireProfileRuntime(context: Context): ProfileRuntime {\n const service = context.get(PROFILE_RUNTIME_SERVICE);\n if (!service) throw new Error('Profile runtime service is unavailable');\n return service;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-runtime': ProfileRuntime;\n }\n}\n","// @scaffold-generated\nimport type { ProfileIntegrationBinding } from '@agimon-ai/po-config/profiles';\nimport { type Context, Service } from '@deepseek-ai/cordis';\n\nimport { PROFILE_SECRETS_SERVICE } from '../../constants/profileSecrets';\nimport type { ProfileProviderFactory, ProfileSecretResolver } from '../profileRuntime/type';\nimport type { ProfileEnvSecretRequest, ProfileSecrets, ProfileSecretsOptions } from './type';\n\n/** Every failure is generic so callers never learn which alias, field or provider response failed. */\nconst UNAVAILABLE = 'Profile secrets are unavailable';\n\nclass HostProfileSecrets implements ProfileSecrets {\n private readonly providers = new Map<string, ProfileProviderFactory>();\n private generation = 0;\n\n constructor(private readonly options: ProfileSecretsOptions) {}\n\n registerProvider(provider: string, factory: ProfileProviderFactory): () => void {\n if (this.providers.has(provider)) throw new Error('Profile secrets provider is already registered');\n this.providers.set(provider, factory);\n return () => {\n if (this.providers.get(provider) === factory) this.providers.delete(provider);\n };\n }\n\n async resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>> {\n if (request.names.length === 0) return {};\n if (new Set(request.names).size !== request.names.length) throw new Error(UNAVAILABLE);\n let binding: ProfileIntegrationBinding | undefined;\n try {\n binding = await this.options.readBinding(request.cwd, request.profile, request.homeDirectory);\n } catch {\n throw new Error(UNAVAILABLE);\n }\n const factory = binding && this.providers.get(binding.provider);\n if (!binding || !factory) throw new Error(UNAVAILABLE);\n const references = request.names.map((name) => {\n const reference = Object.hasOwn(binding.secrets, name) ? binding.secrets[name] : undefined;\n if (!reference?.purposes.includes('env')) throw new Error(UNAVAILABLE);\n return [name, reference] as const;\n });\n\n const controller = new AbortController();\n const signal = request.signal ? AbortSignal.any([controller.signal, request.signal]) : controller.signal;\n let connection: ProfileSecretResolver | undefined;\n try {\n connection = await factory(binding, { profileName: request.profile, generation: ++this.generation, signal });\n const values: Record<string, string> = {};\n for (const [name, reference] of references) {\n const value = await connection.resolveSecret(reference, signal);\n if (signal.aborted || typeof value !== 'string' || value.length === 0) throw new Error(UNAVAILABLE);\n values[name] = value;\n }\n return values;\n } catch {\n throw new Error(UNAVAILABLE);\n } finally {\n controller.abort();\n try {\n await connection?.dispose();\n } catch {\n // Disposal failures are not secret-bearing, but the resolved values are still discarded.\n // oxlint-disable-next-line no-unsafe-finally\n throw new Error(UNAVAILABLE);\n }\n }\n }\n}\n\nexport function createProfileSecrets(options: ProfileSecretsOptions): ProfileSecrets {\n return new HostProfileSecrets(options);\n}\n\n/** Host-side env secret resolution for workflow run steps. Never registered as a model tool. */\nexport class ProfileSecretsService extends Service implements ProfileSecrets {\n constructor(\n context: Context,\n private readonly source: ProfileSecrets,\n ) {\n super(context, PROFILE_SECRETS_SERVICE);\n }\n\n registerProvider(provider: string, factory: ProfileProviderFactory): () => void {\n return this.source.registerProvider(provider, factory);\n }\n\n resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>> {\n return this.source.resolveEnv(request);\n }\n}\n\n/** Include in the extension services array. The helper owns the child fiber. */\nexport function createProfileSecretsPlugin(source: ProfileSecrets): (context: Context) => void {\n return (context: Context): void => {\n new ProfileSecretsService(context, source);\n };\n}\n\nexport function requireProfileSecrets(context: Context): ProfileSecretsService {\n const service = context.get(PROFILE_SECRETS_SERVICE);\n if (!service) throw new Error('Profile secrets service is unavailable');\n return service;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-secrets': ProfileSecretsService;\n }\n}\n","// @scaffold-generated\nimport { type AgentProfile, inlineProfile } from '@agimon-ai/po-config/profiles';\nimport { type Context, Service } from '@deepseek-ai/cordis';\n\nimport { PROFILE_SOURCES_SERVICE } from '../../constants/profileSources';\nimport type { ContributedProfile, ProfileSource, ProfileSources } from './type';\n\nclass HostProfileSources implements ProfileSources {\n private readonly sources = new Map<string, ProfileSource>();\n\n register(id: string, source: ProfileSource): () => void {\n if (this.sources.has(id)) throw new Error('Profile source is already registered');\n this.sources.set(id, source);\n return () => {\n if (this.sources.get(id) === source) this.sources.delete(id);\n };\n }\n\n list(): ContributedProfile[] {\n const byName = new Map<string, ContributedProfile>();\n for (const source of this.sources.values()) {\n let inputs;\n try {\n inputs = source.list();\n } catch {\n continue;\n }\n for (const input of inputs) {\n if (byName.has(input.name)) continue;\n try {\n const profile = inlineProfile(input);\n if (profile.personaPrompt) byName.set(profile.name, { ...profile, personaPrompt: profile.personaPrompt });\n } catch {\n // An invalid definition is skipped like an invalid directory profile.\n }\n }\n }\n return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));\n }\n}\n\nexport function createProfileSources(): ProfileSources {\n return new HostProfileSources();\n}\n\n/** File profiles win; a contributed profile only fills a name the file catalog does not hold. */\nexport function mergeProfiles(files: readonly AgentProfile[], sources: ProfileSources | undefined): AgentProfile[] {\n const names = new Set(files.map(({ name }) => name));\n const contributed = (sources?.list() ?? []).filter(({ name }) => !names.has(name));\n return [...files, ...contributed].sort((left, right) => left.name.localeCompare(right.name));\n}\n\nexport function findProfile(\n files: readonly AgentProfile[],\n sources: ProfileSources | undefined,\n name: string,\n): AgentProfile {\n const profile =\n files.find((candidate) => candidate.name === name) ?? sources?.list().find((candidate) => candidate.name === name);\n if (!profile) throw new Error(`Unknown profile: ${name}`);\n return profile;\n}\n\n/** Profiles plugins hold in memory, merged into the session catalog. Optional: absent means files only. */\nexport class ProfileSourcesService extends Service implements ProfileSources {\n constructor(\n context: Context,\n private readonly source: ProfileSources,\n ) {\n super(context, PROFILE_SOURCES_SERVICE);\n }\n\n register(id: string, source: ProfileSource): () => void {\n return this.source.register(id, source);\n }\n\n list(): ContributedProfile[] {\n return this.source.list();\n }\n}\n\n/** Include in the extension services array. The helper owns the child fiber. */\nexport function createProfileSourcesPlugin(source: ProfileSources): (context: Context) => void {\n return (context: Context): void => {\n new ProfileSourcesService(context, source);\n };\n}\n\nexport function readProfileSources(context: Context): ProfileSources | undefined {\n return context.get(PROFILE_SOURCES_SERVICE);\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-sources': ProfileSourcesService;\n }\n}\n","import type { AgentProfile } from '@agimon-ai/po-config/profiles';\n\nconst NONE = '(none)';\n\n/** Footer status key the cockpit's profile axis reads. */\ninterface SelectItem {\n value: string;\n label: string;\n description?: string;\n}\n\nexport const PROFILE_STATUS_KEY = 'po-profile';\n\n/** Identity this package registers voice capabilities under. */\nexport const PROFILE_SOURCE = '@agimon-ai/po-profile';\n\n/** The command a queued voice switch invokes, and the reload handoff kind it parks. */\nexport const PROFILE_COMMAND = 'profile';\n\n/**\n * The published axis content: the active profile's name, empty while\n * profiles exist with none active, and undefined to withhold the status so\n * the cockpit keeps the axis off the bar entirely.\n */\nexport function profileStatus(current: string | undefined, hasProfiles: boolean): string | undefined {\n if (current) return current;\n return hasProfiles ? '' : undefined;\n}\n\n/** Rows for the single-select profile picker. */\nexport function profileItems(profiles: AgentProfile[]): SelectItem[] {\n return profiles.map((profile) => ({\n value: profile.name,\n label: profile.name,\n description: profileDescription(profile),\n }));\n}\n\nexport function profileDescription(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return environmentKeys.length > 0 ? `${profile.persona} (env: ${environmentKeys.join(', ')})` : profile.persona;\n}\n\n/** Shown when the picked profile is already active. */\nexport function profileSummary(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return [\n `Profile ${profile.name}`,\n `Persona: ${profile.persona}`,\n `Env: ${environmentKeys.join(', ') || NONE}`,\n 'Already loaded.',\n ].join('\\n');\n}\n\nexport function profileTitle(current?: string): string {\n return `Profile (current: ${current ?? NONE})`;\n}\n"],"mappings":";;;AAAA,MAAa,0BAA0B;;;ACCvC,MAAa,0BAA0B;;;ACAvC,MAAa,0BAA0B;;;ACYvC,MAA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;EACf,aAAa,mBAAmB,OAAO;CACzC,EAAE;AACJ;AAEA,SAAgB,mBAAmB,SAA+B;CAChE,MAAM,kBAAkB,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK;CACtD,OAAO,gBAAgB,SAAS,IAAI,GAAG,QAAQ,QAAQ,SAAS,gBAAgB,KAAK,IAAI,EAAE,KAAK,QAAQ;AAC1G;;AAGA,SAAgB,eAAe,SAA+B;CAC5D,MAAM,kBAAkB,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK;CACtD,OAAO;EACL,WAAW,QAAQ;EACnB,YAAY,QAAQ;EACpB,QAAQ,gBAAgB,KAAK,IAAI,KAAK;EACtC;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAgB,aAAa,SAA0B;CACrD,OAAO,qBAAqB,WAAW,KAAK;AAC9C"}
@@ -1,4 +1,4 @@
1
- import { parseProfileBinding } from "@agimon-ai/po-config/profiles";
1
+ import { inlineProfile, parseProfileBinding } from "@agimon-ai/po-config/profiles";
2
2
  import { Service } from "@deepseek-ai/cordis";
3
3
  //#region src/constants/profileRuntime.ts
4
4
  const PROFILE_RUNTIME_SERVICE = "po/profile-runtime";
@@ -6,6 +6,9 @@ const PROFILE_RUNTIME_SERVICE = "po/profile-runtime";
6
6
  //#region src/constants/profileSecrets.ts
7
7
  const PROFILE_SECRETS_SERVICE = "po/profile-secrets";
8
8
  //#endregion
9
+ //#region src/constants/profileSources.ts
10
+ const PROFILE_SOURCES_SERVICE = "po/profile-sources";
11
+ //#endregion
9
12
  //#region src/services/profileRuntime/index.ts
10
13
  const UNAVAILABLE$1 = "Profile integration provider is unavailable";
11
14
  const INVALIDATED = "Profile operation was invalidated";
@@ -291,6 +294,77 @@ function requireProfileSecrets(context) {
291
294
  return service;
292
295
  }
293
296
  //#endregion
297
+ //#region src/services/profileSources/index.ts
298
+ var HostProfileSources = class {
299
+ sources = /* @__PURE__ */ new Map();
300
+ register(id, source) {
301
+ if (this.sources.has(id)) throw new Error("Profile source is already registered");
302
+ this.sources.set(id, source);
303
+ return () => {
304
+ if (this.sources.get(id) === source) this.sources.delete(id);
305
+ };
306
+ }
307
+ list() {
308
+ const byName = /* @__PURE__ */ new Map();
309
+ for (const source of this.sources.values()) {
310
+ let inputs;
311
+ try {
312
+ inputs = source.list();
313
+ } catch {
314
+ continue;
315
+ }
316
+ for (const input of inputs) {
317
+ if (byName.has(input.name)) continue;
318
+ try {
319
+ const profile = inlineProfile(input);
320
+ if (profile.personaPrompt) byName.set(profile.name, {
321
+ ...profile,
322
+ personaPrompt: profile.personaPrompt
323
+ });
324
+ } catch {}
325
+ }
326
+ }
327
+ return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
328
+ }
329
+ };
330
+ function createProfileSources() {
331
+ return new HostProfileSources();
332
+ }
333
+ /** File profiles win; a contributed profile only fills a name the file catalog does not hold. */
334
+ function mergeProfiles(files, sources) {
335
+ const names = new Set(files.map(({ name }) => name));
336
+ const contributed = (sources?.list() ?? []).filter(({ name }) => !names.has(name));
337
+ return [...files, ...contributed].sort((left, right) => left.name.localeCompare(right.name));
338
+ }
339
+ function findProfile(files, sources, name) {
340
+ const profile = files.find((candidate) => candidate.name === name) ?? sources?.list().find((candidate) => candidate.name === name);
341
+ if (!profile) throw new Error(`Unknown profile: ${name}`);
342
+ return profile;
343
+ }
344
+ /** Profiles plugins hold in memory, merged into the session catalog. Optional: absent means files only. */
345
+ var ProfileSourcesService = class extends Service {
346
+ source;
347
+ constructor(context, source) {
348
+ super(context, PROFILE_SOURCES_SERVICE);
349
+ this.source = source;
350
+ }
351
+ register(id, source) {
352
+ return this.source.register(id, source);
353
+ }
354
+ list() {
355
+ return this.source.list();
356
+ }
357
+ };
358
+ /** Include in the extension services array. The helper owns the child fiber. */
359
+ function createProfileSourcesPlugin(source) {
360
+ return (context) => {
361
+ new ProfileSourcesService(context, source);
362
+ };
363
+ }
364
+ function readProfileSources(context) {
365
+ return context.get(PROFILE_SOURCES_SERVICE);
366
+ }
367
+ //#endregion
294
368
  //#region src/services/profileText/index.ts
295
369
  const NONE = "(none)";
296
370
  const PROFILE_STATUS_KEY = "po-profile";
@@ -331,6 +405,6 @@ function profileTitle(current) {
331
405
  return `Profile (current: ${current ?? NONE})`;
332
406
  }
333
407
  //#endregion
334
- export { profileStatus as a, ProfileSecretsService as c, requireProfileSecrets as d, createProfileRuntime as f, PROFILE_RUNTIME_SERVICE as g, PROFILE_SECRETS_SERVICE as h, profileItems as i, createProfileSecrets as l, requireProfileRuntime as m, PROFILE_STATUS_KEY as n, profileSummary as o, createProfileRuntimePlugin as p, profileDescription as r, profileTitle as s, PROFILE_COMMAND as t, createProfileSecretsPlugin as u };
408
+ export { PROFILE_RUNTIME_SERVICE as S, createProfileRuntime as _, profileStatus as a, PROFILE_SOURCES_SERVICE as b, createProfileSources as c, mergeProfiles as d, readProfileSources as f, requireProfileSecrets as g, createProfileSecretsPlugin as h, profileItems as i, createProfileSourcesPlugin as l, createProfileSecrets as m, PROFILE_STATUS_KEY as n, profileSummary as o, ProfileSecretsService as p, profileDescription as r, profileTitle as s, PROFILE_COMMAND as t, findProfile as u, createProfileRuntimePlugin as v, PROFILE_SECRETS_SERVICE as x, requireProfileRuntime as y };
335
409
 
336
- //# sourceMappingURL=profileText-BSQET_iz.mjs.map
410
+ //# sourceMappingURL=profileText-kBfecwbl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileText-kBfecwbl.mjs","names":["UNAVAILABLE"],"sources":["../src/constants/profileRuntime.ts","../src/constants/profileSecrets.ts","../src/constants/profileSources.ts","../src/services/profileRuntime/index.ts","../src/services/profileSecrets/index.ts","../src/services/profileSources/index.ts","../src/services/profileText/index.ts"],"sourcesContent":["export const PROFILE_RUNTIME_SERVICE = 'po/profile-runtime';\n","// @scaffold-generated\nexport const PROFILE_SECRETS_SERVICE = 'po/profile-secrets';\n","// @scaffold-generated\nexport const PROFILE_SOURCES_SERVICE = 'po/profile-sources';\n","import { parseProfileBinding, type ProfileSecretReference } from '@agimon-ai/po-config/profiles';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { PROFILE_RUNTIME_SERVICE } from '../../constants/profileRuntime';\nimport type {\n ProfileProviderFactory,\n ProfileRuntime,\n ProfileRuntimeOptions,\n ProfileRuntimeSnapshot,\n ProfileSecretRequest,\n ProfileSecretResolver,\n} from './type';\n\nconst UNAVAILABLE = 'Profile integration provider is unavailable';\nconst INVALIDATED = 'Profile operation was invalidated';\n\n/** A single selected profile and provider, owned by one session, not a provider registry. */\nclass SessionProfileRuntime implements ProfileRuntime {\n private controller = new AbortController();\n private snapshot: ProfileRuntimeSnapshot;\n private provider?: { name: string; factory: ProfileProviderFactory };\n private connection?: ProfileSecretResolver;\n private transition: Promise<void> = Promise.resolve();\n private retirement: Promise<void> = Promise.resolve();\n private readonly pending = new Set<Promise<void>>();\n private initializing = false;\n private disposed = false;\n private disposal?: Promise<void>;\n\n constructor(private readonly options: ProfileRuntimeOptions) {\n this.snapshot = this.capture(options.profileName, 1);\n }\n\n private capture(profileName: string | undefined, generation: number): ProfileRuntimeSnapshot {\n const binding = profileName === undefined ? undefined : this.options.readBinding(profileName);\n const env = profileName === undefined ? undefined : this.options.readEnv?.(profileName);\n return Object.freeze({\n ...(profileName === undefined ? {} : { profileName }),\n ...(binding === undefined ? {} : { integration: parseProfileBinding(binding) }),\n ...(env === undefined ? {} : { env: Object.freeze({ ...env }) }),\n generation,\n signal: this.controller.signal,\n });\n }\n\n readSelection(): ProfileRuntimeSnapshot {\n return this.snapshot;\n }\n\n invalidate(): void {\n this.controller.abort();\n const connection = this.connection;\n this.connection = undefined;\n if (connection) {\n this.retirement = this.retirement.then(async () => {\n try {\n await connection.dispose();\n } catch {\n throw new Error('Profile provider disposal failed');\n }\n });\n void this.track(this.retirement);\n }\n }\n\n private track(work: Promise<void>): Promise<void> {\n this.pending.add(work);\n // Keep rejection observable through ready/dispose while preventing an unhandled\n // rejection when selection invalidates an initialization before its owner awaits it.\n void work.then(\n () => this.pending.delete(work),\n () => this.pending.delete(work),\n );\n return work;\n }\n\n private initialize(): Promise<void> {\n const snapshot = this.snapshot;\n const provider = this.provider;\n this.initializing = Boolean(snapshot.integration && provider);\n const work = (async () => {\n await this.retirement;\n if (snapshot.signal.aborted) return;\n if (!snapshot.integration || !provider) return;\n if (snapshot.integration.provider !== provider.name) throw new Error(UNAVAILABLE);\n let connection: ProfileSecretResolver;\n try {\n connection = await provider.factory(snapshot.integration, {\n profileName: snapshot.profileName!,\n generation: snapshot.generation,\n signal: snapshot.signal,\n });\n } catch {\n // A retired factory commonly rejects on abort. That cannot remove the\n // provider attachment or poison the replacement generation.\n if (snapshot.signal.aborted) return;\n throw new Error('Profile provider initialization failed');\n }\n if (snapshot.signal.aborted || this.snapshot !== snapshot || this.disposed) {\n try {\n await connection.dispose();\n } catch {\n throw new Error('Profile provider disposal failed');\n }\n return;\n }\n this.connection = connection;\n })();\n this.transition = this.track(\n work.finally(() => {\n if (this.snapshot === snapshot) this.initializing = false;\n }),\n );\n return this.transition;\n }\n\n async select(profileName?: string): Promise<void> {\n if (this.disposed) throw new Error(INVALIDATED);\n if (\n this.snapshot.profileName === profileName &&\n !this.snapshot.signal.aborted &&\n (!this.snapshot.integration || !this.provider || this.connection || this.initializing)\n )\n return;\n this.invalidate();\n this.controller = new AbortController();\n // If reading/validation fails, leave the old generation aborted, never usable.\n this.snapshot = this.capture(profileName, this.snapshot.generation + 1);\n await this.initialize();\n }\n\n async ready(): Promise<void> {\n const snapshot = this.snapshot;\n await this.transition;\n if (this.disposed || snapshot.signal.aborted || this.snapshot !== snapshot) throw new Error(INVALIDATED);\n if (snapshot.integration && !this.connection) throw new Error(UNAVAILABLE);\n }\n\n async attachProvider(providerName: string, factory: ProfileProviderFactory): Promise<() => Promise<void>> {\n if (this.disposed || this.snapshot.signal.aborted) throw new Error(INVALIDATED);\n if (this.provider) throw new Error('Profile provider is already attached');\n if (this.snapshot.integration && this.snapshot.integration.provider !== providerName) throw new Error(UNAVAILABLE);\n const provider = { name: providerName, factory };\n this.provider = provider;\n try {\n await this.initialize();\n await this.ready();\n if (this.disposed || this.provider !== provider) throw new Error(INVALIDATED);\n } catch {\n if (this.provider === provider) this.provider = undefined;\n this.invalidate();\n throw new Error('Profile provider initialization failed');\n }\n let detached = false;\n return async () => {\n if (detached || this.provider !== provider) return;\n detached = true;\n this.invalidate();\n this.provider = undefined;\n this.controller = new AbortController();\n this.snapshot = Object.freeze({\n ...this.snapshot,\n generation: this.snapshot.generation + 1,\n signal: this.controller.signal,\n });\n await this.retirement;\n };\n }\n\n resolveSecret(name: string, request: ProfileSecretRequest): Promise<string> {\n return this.resolveReference(name, request.signal, (reference) => {\n if (!reference.purposes.includes('browser')) throw new Error('Profile secret alias is unavailable');\n if (!reference.allowedOrigins.includes(request.origin)) throw new Error('Profile secret origin is not allowed');\n });\n }\n\n resolveProxySecret(signal?: AbortSignal): Promise<string> {\n const name = this.snapshot.integration?.browser?.proxySecret;\n if (name === undefined) return Promise.reject(new Error('Profile proxy is not configured'));\n return this.resolveReference(name, signal, (reference) => {\n if (!reference.purposes.includes('proxy')) throw new Error('Profile secret alias is unavailable');\n });\n }\n\n private async resolveReference(\n name: string,\n requestSignal: AbortSignal | undefined,\n authorize: (reference: ProfileSecretReference) => void,\n ): Promise<string> {\n // Do not await ready here: a provider factory invoking this callback would\n // otherwise wait for itself. Browser creation may retain, but not invoke it.\n if (this.initializing) throw new Error('Profile secrets are unavailable during provider initialization');\n await this.ready();\n const snapshot = this.snapshot;\n const connection = this.connection;\n const reference = snapshot.integration?.secrets[name];\n if (!connection || !reference || !Object.hasOwn(snapshot.integration!.secrets, name)) {\n throw new Error('Profile secret alias is unavailable');\n }\n authorize(reference);\n const signal = requestSignal ? AbortSignal.any([snapshot.signal, requestSignal]) : snapshot.signal;\n if (signal.aborted) throw new Error(INVALIDATED);\n let value: string;\n try {\n value = await connection.resolveSecret(reference, signal);\n } catch {\n // Provider failures must not leak API responses, credential fields or secrets.\n throw new Error('Profile secret resolution failed');\n }\n if (signal.aborted || this.snapshot !== snapshot || this.connection !== connection) throw new Error(INVALIDATED);\n if (typeof value !== 'string' || value.length === 0) throw new Error('Profile secret field is unavailable');\n return value;\n }\n\n dispose(): Promise<void> {\n if (this.disposal) return this.disposal;\n this.disposed = true;\n this.invalidate();\n this.provider = undefined;\n this.disposal = (async () => {\n const results = await Promise.allSettled([...this.pending, this.retirement]);\n if (results.some((result) => result.status === 'rejected')) throw new Error('Profile runtime disposal failed');\n })();\n return this.disposal;\n }\n}\n\nexport function createProfileRuntime(options: ProfileRuntimeOptions): ProfileRuntime {\n return new SessionProfileRuntime(options);\n}\n\n/** Mounted in the scoped root services array, before dependent integration tools. */\nexport function createProfileRuntimePlugin(runtime: ProfileRuntime): (context: Context) => void {\n return (context) => {\n context.provide(PROFILE_RUNTIME_SERVICE, runtime);\n };\n}\n\nexport function requireProfileRuntime(context: Context): ProfileRuntime {\n const service = context.get(PROFILE_RUNTIME_SERVICE);\n if (!service) throw new Error('Profile runtime service is unavailable');\n return service;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-runtime': ProfileRuntime;\n }\n}\n","// @scaffold-generated\nimport type { ProfileIntegrationBinding } from '@agimon-ai/po-config/profiles';\nimport { type Context, Service } from '@deepseek-ai/cordis';\n\nimport { PROFILE_SECRETS_SERVICE } from '../../constants/profileSecrets';\nimport type { ProfileProviderFactory, ProfileSecretResolver } from '../profileRuntime/type';\nimport type { ProfileEnvSecretRequest, ProfileSecrets, ProfileSecretsOptions } from './type';\n\n/** Every failure is generic so callers never learn which alias, field or provider response failed. */\nconst UNAVAILABLE = 'Profile secrets are unavailable';\n\nclass HostProfileSecrets implements ProfileSecrets {\n private readonly providers = new Map<string, ProfileProviderFactory>();\n private generation = 0;\n\n constructor(private readonly options: ProfileSecretsOptions) {}\n\n registerProvider(provider: string, factory: ProfileProviderFactory): () => void {\n if (this.providers.has(provider)) throw new Error('Profile secrets provider is already registered');\n this.providers.set(provider, factory);\n return () => {\n if (this.providers.get(provider) === factory) this.providers.delete(provider);\n };\n }\n\n async resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>> {\n if (request.names.length === 0) return {};\n if (new Set(request.names).size !== request.names.length) throw new Error(UNAVAILABLE);\n let binding: ProfileIntegrationBinding | undefined;\n try {\n binding = await this.options.readBinding(request.cwd, request.profile, request.homeDirectory);\n } catch {\n throw new Error(UNAVAILABLE);\n }\n const factory = binding && this.providers.get(binding.provider);\n if (!binding || !factory) throw new Error(UNAVAILABLE);\n const references = request.names.map((name) => {\n const reference = Object.hasOwn(binding.secrets, name) ? binding.secrets[name] : undefined;\n if (!reference?.purposes.includes('env')) throw new Error(UNAVAILABLE);\n return [name, reference] as const;\n });\n\n const controller = new AbortController();\n const signal = request.signal ? AbortSignal.any([controller.signal, request.signal]) : controller.signal;\n let connection: ProfileSecretResolver | undefined;\n try {\n connection = await factory(binding, { profileName: request.profile, generation: ++this.generation, signal });\n const values: Record<string, string> = {};\n for (const [name, reference] of references) {\n const value = await connection.resolveSecret(reference, signal);\n if (signal.aborted || typeof value !== 'string' || value.length === 0) throw new Error(UNAVAILABLE);\n values[name] = value;\n }\n return values;\n } catch {\n throw new Error(UNAVAILABLE);\n } finally {\n controller.abort();\n try {\n await connection?.dispose();\n } catch {\n // Disposal failures are not secret-bearing, but the resolved values are still discarded.\n // oxlint-disable-next-line no-unsafe-finally\n throw new Error(UNAVAILABLE);\n }\n }\n }\n}\n\nexport function createProfileSecrets(options: ProfileSecretsOptions): ProfileSecrets {\n return new HostProfileSecrets(options);\n}\n\n/** Host-side env secret resolution for workflow run steps. Never registered as a model tool. */\nexport class ProfileSecretsService extends Service implements ProfileSecrets {\n constructor(\n context: Context,\n private readonly source: ProfileSecrets,\n ) {\n super(context, PROFILE_SECRETS_SERVICE);\n }\n\n registerProvider(provider: string, factory: ProfileProviderFactory): () => void {\n return this.source.registerProvider(provider, factory);\n }\n\n resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>> {\n return this.source.resolveEnv(request);\n }\n}\n\n/** Include in the extension services array. The helper owns the child fiber. */\nexport function createProfileSecretsPlugin(source: ProfileSecrets): (context: Context) => void {\n return (context: Context): void => {\n new ProfileSecretsService(context, source);\n };\n}\n\nexport function requireProfileSecrets(context: Context): ProfileSecretsService {\n const service = context.get(PROFILE_SECRETS_SERVICE);\n if (!service) throw new Error('Profile secrets service is unavailable');\n return service;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-secrets': ProfileSecretsService;\n }\n}\n","// @scaffold-generated\nimport { type AgentProfile, inlineProfile } from '@agimon-ai/po-config/profiles';\nimport { type Context, Service } from '@deepseek-ai/cordis';\n\nimport { PROFILE_SOURCES_SERVICE } from '../../constants/profileSources';\nimport type { ContributedProfile, ProfileSource, ProfileSources } from './type';\n\nclass HostProfileSources implements ProfileSources {\n private readonly sources = new Map<string, ProfileSource>();\n\n register(id: string, source: ProfileSource): () => void {\n if (this.sources.has(id)) throw new Error('Profile source is already registered');\n this.sources.set(id, source);\n return () => {\n if (this.sources.get(id) === source) this.sources.delete(id);\n };\n }\n\n list(): ContributedProfile[] {\n const byName = new Map<string, ContributedProfile>();\n for (const source of this.sources.values()) {\n let inputs;\n try {\n inputs = source.list();\n } catch {\n continue;\n }\n for (const input of inputs) {\n if (byName.has(input.name)) continue;\n try {\n const profile = inlineProfile(input);\n if (profile.personaPrompt) byName.set(profile.name, { ...profile, personaPrompt: profile.personaPrompt });\n } catch {\n // An invalid definition is skipped like an invalid directory profile.\n }\n }\n }\n return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));\n }\n}\n\nexport function createProfileSources(): ProfileSources {\n return new HostProfileSources();\n}\n\n/** File profiles win; a contributed profile only fills a name the file catalog does not hold. */\nexport function mergeProfiles(files: readonly AgentProfile[], sources: ProfileSources | undefined): AgentProfile[] {\n const names = new Set(files.map(({ name }) => name));\n const contributed = (sources?.list() ?? []).filter(({ name }) => !names.has(name));\n return [...files, ...contributed].sort((left, right) => left.name.localeCompare(right.name));\n}\n\nexport function findProfile(\n files: readonly AgentProfile[],\n sources: ProfileSources | undefined,\n name: string,\n): AgentProfile {\n const profile =\n files.find((candidate) => candidate.name === name) ?? sources?.list().find((candidate) => candidate.name === name);\n if (!profile) throw new Error(`Unknown profile: ${name}`);\n return profile;\n}\n\n/** Profiles plugins hold in memory, merged into the session catalog. Optional: absent means files only. */\nexport class ProfileSourcesService extends Service implements ProfileSources {\n constructor(\n context: Context,\n private readonly source: ProfileSources,\n ) {\n super(context, PROFILE_SOURCES_SERVICE);\n }\n\n register(id: string, source: ProfileSource): () => void {\n return this.source.register(id, source);\n }\n\n list(): ContributedProfile[] {\n return this.source.list();\n }\n}\n\n/** Include in the extension services array. The helper owns the child fiber. */\nexport function createProfileSourcesPlugin(source: ProfileSources): (context: Context) => void {\n return (context: Context): void => {\n new ProfileSourcesService(context, source);\n };\n}\n\nexport function readProfileSources(context: Context): ProfileSources | undefined {\n return context.get(PROFILE_SOURCES_SERVICE);\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-sources': ProfileSourcesService;\n }\n}\n","import type { AgentProfile } from '@agimon-ai/po-config/profiles';\n\nconst NONE = '(none)';\n\n/** Footer status key the cockpit's profile axis reads. */\ninterface SelectItem {\n value: string;\n label: string;\n description?: string;\n}\n\nexport const PROFILE_STATUS_KEY = 'po-profile';\n\n/** Identity this package registers voice capabilities under. */\nexport const PROFILE_SOURCE = '@agimon-ai/po-profile';\n\n/** The command a queued voice switch invokes, and the reload handoff kind it parks. */\nexport const PROFILE_COMMAND = 'profile';\n\n/**\n * The published axis content: the active profile's name, empty while\n * profiles exist with none active, and undefined to withhold the status so\n * the cockpit keeps the axis off the bar entirely.\n */\nexport function profileStatus(current: string | undefined, hasProfiles: boolean): string | undefined {\n if (current) return current;\n return hasProfiles ? '' : undefined;\n}\n\n/** Rows for the single-select profile picker. */\nexport function profileItems(profiles: AgentProfile[]): SelectItem[] {\n return profiles.map((profile) => ({\n value: profile.name,\n label: profile.name,\n description: profileDescription(profile),\n }));\n}\n\nexport function profileDescription(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return environmentKeys.length > 0 ? `${profile.persona} (env: ${environmentKeys.join(', ')})` : profile.persona;\n}\n\n/** Shown when the picked profile is already active. */\nexport function profileSummary(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return [\n `Profile ${profile.name}`,\n `Persona: ${profile.persona}`,\n `Env: ${environmentKeys.join(', ') || NONE}`,\n 'Already loaded.',\n ].join('\\n');\n}\n\nexport function profileTitle(current?: string): string {\n return `Profile (current: ${current ?? NONE})`;\n}\n"],"mappings":";;;AAAA,MAAa,0BAA0B;;;ACCvC,MAAa,0BAA0B;;;ACAvC,MAAa,0BAA0B;;;ACYvC,MAAMA,gBAAc;AACpB,MAAM,cAAc;;AAGpB,IAAM,wBAAN,MAAsD;CAYvB;CAX7B,aAAqB,IAAI,gBAAgB;CACzC;CACA;CACA;CACA,aAAoC,QAAQ,QAAQ;CACpD,aAAoC,QAAQ,QAAQ;CACpD,0BAA2B,IAAI,IAAmB;CAClD,eAAuB;CACvB,WAAmB;CACnB;CAEA,YAAY,SAAiD;EAAhC,KAAA,UAAA;EAC3B,KAAK,WAAW,KAAK,QAAQ,QAAQ,aAAa,CAAC;CACrD;CAEA,QAAgB,aAAiC,YAA4C;EAC3F,MAAM,UAAU,gBAAgB,KAAA,IAAY,KAAA,IAAY,KAAK,QAAQ,YAAY,WAAW;EAC5F,MAAM,MAAM,gBAAgB,KAAA,IAAY,KAAA,IAAY,KAAK,QAAQ,UAAU,WAAW;EACtF,OAAO,OAAO,OAAO;GACnB,GAAI,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY;GACnD,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,oBAAoB,OAAO,EAAE;GAC7E,GAAI,QAAQ,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK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AAK,OAAO,KAAK;CAC1B;AACF;;AAGA,SAAgB,2BAA2B,QAAoD;CAC7F,QAAQ,YAA2B;EACjC,IAAI,sBAAsB,SAAS,MAAM;CAC3C;AACF;AAEA,SAAgB,mBAAmB,SAA8C;CAC/E,OAAO,QAAQ,IAAI,uBAAuB;AAC5C;;;ACxFA,MAAM,OAAO;AASb,MAAa,qBAAqB;;AAMlC,MAAa,kBAAkB;;;;;;AAO/B,SAAgB,cAAc,SAA6B,aAA0C;CACnG,IAAI,SAAS,OAAO;CACpB,OAAO,cAAc,KAAK,KAAA;AAC5B;;AAGA,SAAgB,aAAa,UAAwC;CACnE,OAAO,SAAS,KAAK,aAAa;EAChC,OAAO,QAAQ;EACf,OAAO,QAAQ;EACf,aAAa,mBAAmB,OAAO;CACzC,EAAE;AACJ;AAEA,SAAgB,mBAAmB,SAA+B;CAChE,MAAM,kBAAkB,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK;CACtD,OAAO,gBAAgB,SAAS,IAAI,GAAG,QAAQ,QAAQ,SAAS,gBAAgB,KAAK,IAAI,EAAE,KAAK,QAAQ;AAC1G;;AAGA,SAAgB,eAAe,SAA+B;CAC5D,MAAM,kBAAkB,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK;CACtD,OAAO;EACL,WAAW,QAAQ;EACnB,YAAY,QAAQ;EACpB,QAAQ,gBAAgB,KAAK,IAAI,KAAK;EACtC;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAgB,aAAa,SAA0B;CACrD,OAAO,qBAAqB,WAAW,KAAK;AAC9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-profile",
3
- "version": "0.0.0-alpha.39",
3
+ "version": "0.0.0-alpha.40",
4
4
  "description": "Persona and environment profile switching for Po sessions.",
5
5
  "keywords": [
6
6
  "agent-persona",
@@ -66,17 +66,17 @@
66
66
  "access": "public"
67
67
  },
68
68
  "dependencies": {
69
- "@agimon-ai/po-config": "0.0.0-alpha.39",
70
- "@agimon-ai/po-core": "0.0.0-alpha.39",
71
- "@agimon-ai/po-minor-mode": "0.0.0-alpha.39",
69
+ "@agimon-ai/po-config": "0.0.0-alpha.40",
70
+ "@agimon-ai/po-core": "0.0.0-alpha.40",
71
+ "@agimon-ai/po-minor-mode": "0.0.0-alpha.40",
72
72
  "@deepseek-ai/cordis": "4.0.5",
73
73
  "typebox": "1.4.2"
74
74
  },
75
75
  "devDependencies": {
76
- "@agimon-ai/po-build": "0.0.0-alpha.39",
77
- "@agimon-ai/po-core": "0.0.0-alpha.39",
78
- "@agimon-ai/po-voice": "0.0.0-alpha.39",
79
- "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.39",
76
+ "@agimon-ai/po-build": "0.0.0-alpha.40",
77
+ "@agimon-ai/po-core": "0.0.0-alpha.40",
78
+ "@agimon-ai/po-voice": "0.0.0-alpha.40",
79
+ "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.40",
80
80
  "@deepseek-ai/cordis": "4.0.5",
81
81
  "@earendil-works/pi-coding-agent": "1.3.0",
82
82
  "@types/node": "26.6.5",
@@ -86,7 +86,7 @@
86
86
  "vitest": "5.0.4"
87
87
  },
88
88
  "peerDependencies": {
89
- "@agimon-ai/po-core": "0.0.0-alpha.39",
89
+ "@agimon-ai/po-core": "0.0.0-alpha.40",
90
90
  "@earendil-works/pi-coding-agent": "1.3.0"
91
91
  },
92
92
  "peerDependenciesMeta": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"profileText-BSQET_iz.mjs","names":["UNAVAILABLE"],"sources":["../src/constants/profileRuntime.ts","../src/constants/profileSecrets.ts","../src/services/profileRuntime/index.ts","../src/services/profileSecrets/index.ts","../src/services/profileText/index.ts"],"sourcesContent":["export const PROFILE_RUNTIME_SERVICE = 'po/profile-runtime';\n","// @scaffold-generated\nexport const PROFILE_SECRETS_SERVICE = 'po/profile-secrets';\n","import { parseProfileBinding, type ProfileSecretReference } from '@agimon-ai/po-config/profiles';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { PROFILE_RUNTIME_SERVICE } from '../../constants/profileRuntime';\nimport type {\n ProfileProviderFactory,\n ProfileRuntime,\n ProfileRuntimeOptions,\n ProfileRuntimeSnapshot,\n ProfileSecretRequest,\n ProfileSecretResolver,\n} from './type';\n\nconst UNAVAILABLE = 'Profile integration provider is unavailable';\nconst INVALIDATED = 'Profile operation was invalidated';\n\n/** A single selected profile and provider, owned by one session, not a provider registry. */\nclass SessionProfileRuntime implements ProfileRuntime {\n private controller = new AbortController();\n private snapshot: ProfileRuntimeSnapshot;\n private provider?: { name: string; factory: ProfileProviderFactory };\n private connection?: ProfileSecretResolver;\n private transition: Promise<void> = Promise.resolve();\n private retirement: Promise<void> = Promise.resolve();\n private readonly pending = new Set<Promise<void>>();\n private initializing = false;\n private disposed = false;\n private disposal?: Promise<void>;\n\n constructor(private readonly options: ProfileRuntimeOptions) {\n this.snapshot = this.capture(options.profileName, 1);\n }\n\n private capture(profileName: string | undefined, generation: number): ProfileRuntimeSnapshot {\n const binding = profileName === undefined ? undefined : this.options.readBinding(profileName);\n const env = profileName === undefined ? undefined : this.options.readEnv?.(profileName);\n return Object.freeze({\n ...(profileName === undefined ? {} : { profileName }),\n ...(binding === undefined ? {} : { integration: parseProfileBinding(binding) }),\n ...(env === undefined ? {} : { env: Object.freeze({ ...env }) }),\n generation,\n signal: this.controller.signal,\n });\n }\n\n readSelection(): ProfileRuntimeSnapshot {\n return this.snapshot;\n }\n\n invalidate(): void {\n this.controller.abort();\n const connection = this.connection;\n this.connection = undefined;\n if (connection) {\n this.retirement = this.retirement.then(async () => {\n try {\n await connection.dispose();\n } catch {\n throw new Error('Profile provider disposal failed');\n }\n });\n void this.track(this.retirement);\n }\n }\n\n private track(work: Promise<void>): Promise<void> {\n this.pending.add(work);\n // Keep rejection observable through ready/dispose while preventing an unhandled\n // rejection when selection invalidates an initialization before its owner awaits it.\n void work.then(\n () => this.pending.delete(work),\n () => this.pending.delete(work),\n );\n return work;\n }\n\n private initialize(): Promise<void> {\n const snapshot = this.snapshot;\n const provider = this.provider;\n this.initializing = Boolean(snapshot.integration && provider);\n const work = (async () => {\n await this.retirement;\n if (snapshot.signal.aborted) return;\n if (!snapshot.integration || !provider) return;\n if (snapshot.integration.provider !== provider.name) throw new Error(UNAVAILABLE);\n let connection: ProfileSecretResolver;\n try {\n connection = await provider.factory(snapshot.integration, {\n profileName: snapshot.profileName!,\n generation: snapshot.generation,\n signal: snapshot.signal,\n });\n } catch {\n // A retired factory commonly rejects on abort. That cannot remove the\n // provider attachment or poison the replacement generation.\n if (snapshot.signal.aborted) return;\n throw new Error('Profile provider initialization failed');\n }\n if (snapshot.signal.aborted || this.snapshot !== snapshot || this.disposed) {\n try {\n await connection.dispose();\n } catch {\n throw new Error('Profile provider disposal failed');\n }\n return;\n }\n this.connection = connection;\n })();\n this.transition = this.track(\n work.finally(() => {\n if (this.snapshot === snapshot) this.initializing = false;\n }),\n );\n return this.transition;\n }\n\n async select(profileName?: string): Promise<void> {\n if (this.disposed) throw new Error(INVALIDATED);\n if (\n this.snapshot.profileName === profileName &&\n !this.snapshot.signal.aborted &&\n (!this.snapshot.integration || !this.provider || this.connection || this.initializing)\n )\n return;\n this.invalidate();\n this.controller = new AbortController();\n // If reading/validation fails, leave the old generation aborted, never usable.\n this.snapshot = this.capture(profileName, this.snapshot.generation + 1);\n await this.initialize();\n }\n\n async ready(): Promise<void> {\n const snapshot = this.snapshot;\n await this.transition;\n if (this.disposed || snapshot.signal.aborted || this.snapshot !== snapshot) throw new Error(INVALIDATED);\n if (snapshot.integration && !this.connection) throw new Error(UNAVAILABLE);\n }\n\n async attachProvider(providerName: string, factory: ProfileProviderFactory): Promise<() => Promise<void>> {\n if (this.disposed || this.snapshot.signal.aborted) throw new Error(INVALIDATED);\n if (this.provider) throw new Error('Profile provider is already attached');\n if (this.snapshot.integration && this.snapshot.integration.provider !== providerName) throw new Error(UNAVAILABLE);\n const provider = { name: providerName, factory };\n this.provider = provider;\n try {\n await this.initialize();\n await this.ready();\n if (this.disposed || this.provider !== provider) throw new Error(INVALIDATED);\n } catch {\n if (this.provider === provider) this.provider = undefined;\n this.invalidate();\n throw new Error('Profile provider initialization failed');\n }\n let detached = false;\n return async () => {\n if (detached || this.provider !== provider) return;\n detached = true;\n this.invalidate();\n this.provider = undefined;\n this.controller = new AbortController();\n this.snapshot = Object.freeze({\n ...this.snapshot,\n generation: this.snapshot.generation + 1,\n signal: this.controller.signal,\n });\n await this.retirement;\n };\n }\n\n resolveSecret(name: string, request: ProfileSecretRequest): Promise<string> {\n return this.resolveReference(name, request.signal, (reference) => {\n if (!reference.purposes.includes('browser')) throw new Error('Profile secret alias is unavailable');\n if (!reference.allowedOrigins.includes(request.origin)) throw new Error('Profile secret origin is not allowed');\n });\n }\n\n resolveProxySecret(signal?: AbortSignal): Promise<string> {\n const name = this.snapshot.integration?.browser?.proxySecret;\n if (name === undefined) return Promise.reject(new Error('Profile proxy is not configured'));\n return this.resolveReference(name, signal, (reference) => {\n if (!reference.purposes.includes('proxy')) throw new Error('Profile secret alias is unavailable');\n });\n }\n\n private async resolveReference(\n name: string,\n requestSignal: AbortSignal | undefined,\n authorize: (reference: ProfileSecretReference) => void,\n ): Promise<string> {\n // Do not await ready here: a provider factory invoking this callback would\n // otherwise wait for itself. Browser creation may retain, but not invoke it.\n if (this.initializing) throw new Error('Profile secrets are unavailable during provider initialization');\n await this.ready();\n const snapshot = this.snapshot;\n const connection = this.connection;\n const reference = snapshot.integration?.secrets[name];\n if (!connection || !reference || !Object.hasOwn(snapshot.integration!.secrets, name)) {\n throw new Error('Profile secret alias is unavailable');\n }\n authorize(reference);\n const signal = requestSignal ? AbortSignal.any([snapshot.signal, requestSignal]) : snapshot.signal;\n if (signal.aborted) throw new Error(INVALIDATED);\n let value: string;\n try {\n value = await connection.resolveSecret(reference, signal);\n } catch {\n // Provider failures must not leak API responses, credential fields or secrets.\n throw new Error('Profile secret resolution failed');\n }\n if (signal.aborted || this.snapshot !== snapshot || this.connection !== connection) throw new Error(INVALIDATED);\n if (typeof value !== 'string' || value.length === 0) throw new Error('Profile secret field is unavailable');\n return value;\n }\n\n dispose(): Promise<void> {\n if (this.disposal) return this.disposal;\n this.disposed = true;\n this.invalidate();\n this.provider = undefined;\n this.disposal = (async () => {\n const results = await Promise.allSettled([...this.pending, this.retirement]);\n if (results.some((result) => result.status === 'rejected')) throw new Error('Profile runtime disposal failed');\n })();\n return this.disposal;\n }\n}\n\nexport function createProfileRuntime(options: ProfileRuntimeOptions): ProfileRuntime {\n return new SessionProfileRuntime(options);\n}\n\n/** Mounted in the scoped root services array, before dependent integration tools. */\nexport function createProfileRuntimePlugin(runtime: ProfileRuntime): (context: Context) => void {\n return (context) => {\n context.provide(PROFILE_RUNTIME_SERVICE, runtime);\n };\n}\n\nexport function requireProfileRuntime(context: Context): ProfileRuntime {\n const service = context.get(PROFILE_RUNTIME_SERVICE);\n if (!service) throw new Error('Profile runtime service is unavailable');\n return service;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-runtime': ProfileRuntime;\n }\n}\n","// @scaffold-generated\nimport type { ProfileIntegrationBinding } from '@agimon-ai/po-config/profiles';\nimport { type Context, Service } from '@deepseek-ai/cordis';\n\nimport { PROFILE_SECRETS_SERVICE } from '../../constants/profileSecrets';\nimport type { ProfileProviderFactory, ProfileSecretResolver } from '../profileRuntime/type';\nimport type { ProfileEnvSecretRequest, ProfileSecrets, ProfileSecretsOptions } from './type';\n\n/** Every failure is generic so callers never learn which alias, field or provider response failed. */\nconst UNAVAILABLE = 'Profile secrets are unavailable';\n\nclass HostProfileSecrets implements ProfileSecrets {\n private readonly providers = new Map<string, ProfileProviderFactory>();\n private generation = 0;\n\n constructor(private readonly options: ProfileSecretsOptions) {}\n\n registerProvider(provider: string, factory: ProfileProviderFactory): () => void {\n if (this.providers.has(provider)) throw new Error('Profile secrets provider is already registered');\n this.providers.set(provider, factory);\n return () => {\n if (this.providers.get(provider) === factory) this.providers.delete(provider);\n };\n }\n\n async resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>> {\n if (request.names.length === 0) return {};\n if (new Set(request.names).size !== request.names.length) throw new Error(UNAVAILABLE);\n let binding: ProfileIntegrationBinding | undefined;\n try {\n binding = await this.options.readBinding(request.cwd, request.profile, request.homeDirectory);\n } catch {\n throw new Error(UNAVAILABLE);\n }\n const factory = binding && this.providers.get(binding.provider);\n if (!binding || !factory) throw new Error(UNAVAILABLE);\n const references = request.names.map((name) => {\n const reference = Object.hasOwn(binding.secrets, name) ? binding.secrets[name] : undefined;\n if (!reference?.purposes.includes('env')) throw new Error(UNAVAILABLE);\n return [name, reference] as const;\n });\n\n const controller = new AbortController();\n const signal = request.signal ? AbortSignal.any([controller.signal, request.signal]) : controller.signal;\n let connection: ProfileSecretResolver | undefined;\n try {\n connection = await factory(binding, { profileName: request.profile, generation: ++this.generation, signal });\n const values: Record<string, string> = {};\n for (const [name, reference] of references) {\n const value = await connection.resolveSecret(reference, signal);\n if (signal.aborted || typeof value !== 'string' || value.length === 0) throw new Error(UNAVAILABLE);\n values[name] = value;\n }\n return values;\n } catch {\n throw new Error(UNAVAILABLE);\n } finally {\n controller.abort();\n try {\n await connection?.dispose();\n } catch {\n // Disposal failures are not secret-bearing, but the resolved values are still discarded.\n // oxlint-disable-next-line no-unsafe-finally\n throw new Error(UNAVAILABLE);\n }\n }\n }\n}\n\nexport function createProfileSecrets(options: ProfileSecretsOptions): ProfileSecrets {\n return new HostProfileSecrets(options);\n}\n\n/** Host-side env secret resolution for workflow run steps. Never registered as a model tool. */\nexport class ProfileSecretsService extends Service implements ProfileSecrets {\n constructor(\n context: Context,\n private readonly source: ProfileSecrets,\n ) {\n super(context, PROFILE_SECRETS_SERVICE);\n }\n\n registerProvider(provider: string, factory: ProfileProviderFactory): () => void {\n return this.source.registerProvider(provider, factory);\n }\n\n resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>> {\n return this.source.resolveEnv(request);\n }\n}\n\n/** Include in the extension services array. The helper owns the child fiber. */\nexport function createProfileSecretsPlugin(source: ProfileSecrets): (context: Context) => void {\n return (context: Context): void => {\n new ProfileSecretsService(context, source);\n };\n}\n\nexport function requireProfileSecrets(context: Context): ProfileSecretsService {\n const service = context.get(PROFILE_SECRETS_SERVICE);\n if (!service) throw new Error('Profile secrets service is unavailable');\n return service;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-secrets': ProfileSecretsService;\n }\n}\n","import type { AgentProfile } from '@agimon-ai/po-config/profiles';\n\nconst NONE = '(none)';\n\n/** Footer status key the cockpit's profile axis reads. */\ninterface SelectItem {\n value: string;\n label: string;\n description?: string;\n}\n\nexport const PROFILE_STATUS_KEY = 'po-profile';\n\n/** Identity this package registers voice capabilities under. */\nexport const PROFILE_SOURCE = '@agimon-ai/po-profile';\n\n/** The command a queued voice switch invokes, and the reload handoff kind it parks. */\nexport const PROFILE_COMMAND = 'profile';\n\n/**\n * The published axis content: the active profile's name, empty while\n * profiles exist with none active, and undefined to withhold the status so\n * the cockpit keeps the axis off the bar entirely.\n */\nexport function profileStatus(current: string | undefined, hasProfiles: boolean): string | undefined {\n if (current) return current;\n return hasProfiles ? '' : undefined;\n}\n\n/** Rows for the single-select profile picker. */\nexport function profileItems(profiles: AgentProfile[]): SelectItem[] {\n return profiles.map((profile) => ({\n value: profile.name,\n label: profile.name,\n description: profileDescription(profile),\n }));\n}\n\nexport function profileDescription(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return environmentKeys.length > 0 ? `${profile.persona} (env: ${environmentKeys.join(', ')})` : profile.persona;\n}\n\n/** Shown when the picked profile is already active. */\nexport function profileSummary(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return [\n `Profile ${profile.name}`,\n `Persona: ${profile.persona}`,\n `Env: ${environmentKeys.join(', ') || NONE}`,\n 'Already loaded.',\n ].join('\\n');\n}\n\n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
@@ -1 +0,0 @@
1
- {"version":3,"file":"profileText-BSaTvVwa.cjs","names":["UNAVAILABLE","parseProfileBinding","Service"],"sources":["../src/constants/profileRuntime.ts","../src/constants/profileSecrets.ts","../src/services/profileRuntime/index.ts","../src/services/profileSecrets/index.ts","../src/services/profileText/index.ts"],"sourcesContent":["export const PROFILE_RUNTIME_SERVICE = 'po/profile-runtime';\n","// @scaffold-generated\nexport const PROFILE_SECRETS_SERVICE = 'po/profile-secrets';\n","import { parseProfileBinding, type ProfileSecretReference } from '@agimon-ai/po-config/profiles';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { PROFILE_RUNTIME_SERVICE } from '../../constants/profileRuntime';\nimport type {\n ProfileProviderFactory,\n ProfileRuntime,\n ProfileRuntimeOptions,\n ProfileRuntimeSnapshot,\n ProfileSecretRequest,\n ProfileSecretResolver,\n} from './type';\n\nconst UNAVAILABLE = 'Profile integration provider is unavailable';\nconst INVALIDATED = 'Profile operation was invalidated';\n\n/** A single selected profile and provider, owned by one session, not a provider registry. */\nclass SessionProfileRuntime implements ProfileRuntime {\n private controller = new AbortController();\n private snapshot: ProfileRuntimeSnapshot;\n private provider?: { name: string; factory: ProfileProviderFactory };\n private connection?: ProfileSecretResolver;\n private transition: Promise<void> = Promise.resolve();\n private retirement: Promise<void> = Promise.resolve();\n private readonly pending = new Set<Promise<void>>();\n private initializing = false;\n private disposed = false;\n private disposal?: Promise<void>;\n\n constructor(private readonly options: ProfileRuntimeOptions) {\n this.snapshot = this.capture(options.profileName, 1);\n }\n\n private capture(profileName: string | undefined, generation: number): ProfileRuntimeSnapshot {\n const binding = profileName === undefined ? undefined : this.options.readBinding(profileName);\n const env = profileName === undefined ? undefined : this.options.readEnv?.(profileName);\n return Object.freeze({\n ...(profileName === undefined ? {} : { profileName }),\n ...(binding === undefined ? {} : { integration: parseProfileBinding(binding) }),\n ...(env === undefined ? {} : { env: Object.freeze({ ...env }) }),\n generation,\n signal: this.controller.signal,\n });\n }\n\n readSelection(): ProfileRuntimeSnapshot {\n return this.snapshot;\n }\n\n invalidate(): void {\n this.controller.abort();\n const connection = this.connection;\n this.connection = undefined;\n if (connection) {\n this.retirement = this.retirement.then(async () => {\n try {\n await connection.dispose();\n } catch {\n throw new Error('Profile provider disposal failed');\n }\n });\n void this.track(this.retirement);\n }\n }\n\n private track(work: Promise<void>): Promise<void> {\n this.pending.add(work);\n // Keep rejection observable through ready/dispose while preventing an unhandled\n // rejection when selection invalidates an initialization before its owner awaits it.\n void work.then(\n () => this.pending.delete(work),\n () => this.pending.delete(work),\n );\n return work;\n }\n\n private initialize(): Promise<void> {\n const snapshot = this.snapshot;\n const provider = this.provider;\n this.initializing = Boolean(snapshot.integration && provider);\n const work = (async () => {\n await this.retirement;\n if (snapshot.signal.aborted) return;\n if (!snapshot.integration || !provider) return;\n if (snapshot.integration.provider !== provider.name) throw new Error(UNAVAILABLE);\n let connection: ProfileSecretResolver;\n try {\n connection = await provider.factory(snapshot.integration, {\n profileName: snapshot.profileName!,\n generation: snapshot.generation,\n signal: snapshot.signal,\n });\n } catch {\n // A retired factory commonly rejects on abort. That cannot remove the\n // provider attachment or poison the replacement generation.\n if (snapshot.signal.aborted) return;\n throw new Error('Profile provider initialization failed');\n }\n if (snapshot.signal.aborted || this.snapshot !== snapshot || this.disposed) {\n try {\n await connection.dispose();\n } catch {\n throw new Error('Profile provider disposal failed');\n }\n return;\n }\n this.connection = connection;\n })();\n this.transition = this.track(\n work.finally(() => {\n if (this.snapshot === snapshot) this.initializing = false;\n }),\n );\n return this.transition;\n }\n\n async select(profileName?: string): Promise<void> {\n if (this.disposed) throw new Error(INVALIDATED);\n if (\n this.snapshot.profileName === profileName &&\n !this.snapshot.signal.aborted &&\n (!this.snapshot.integration || !this.provider || this.connection || this.initializing)\n )\n return;\n this.invalidate();\n this.controller = new AbortController();\n // If reading/validation fails, leave the old generation aborted, never usable.\n this.snapshot = this.capture(profileName, this.snapshot.generation + 1);\n await this.initialize();\n }\n\n async ready(): Promise<void> {\n const snapshot = this.snapshot;\n await this.transition;\n if (this.disposed || snapshot.signal.aborted || this.snapshot !== snapshot) throw new Error(INVALIDATED);\n if (snapshot.integration && !this.connection) throw new Error(UNAVAILABLE);\n }\n\n async attachProvider(providerName: string, factory: ProfileProviderFactory): Promise<() => Promise<void>> {\n if (this.disposed || this.snapshot.signal.aborted) throw new Error(INVALIDATED);\n if (this.provider) throw new Error('Profile provider is already attached');\n if (this.snapshot.integration && this.snapshot.integration.provider !== providerName) throw new Error(UNAVAILABLE);\n const provider = { name: providerName, factory };\n this.provider = provider;\n try {\n await this.initialize();\n await this.ready();\n if (this.disposed || this.provider !== provider) throw new Error(INVALIDATED);\n } catch {\n if (this.provider === provider) this.provider = undefined;\n this.invalidate();\n throw new Error('Profile provider initialization failed');\n }\n let detached = false;\n return async () => {\n if (detached || this.provider !== provider) return;\n detached = true;\n this.invalidate();\n this.provider = undefined;\n this.controller = new AbortController();\n this.snapshot = Object.freeze({\n ...this.snapshot,\n generation: this.snapshot.generation + 1,\n signal: this.controller.signal,\n });\n await this.retirement;\n };\n }\n\n resolveSecret(name: string, request: ProfileSecretRequest): Promise<string> {\n return this.resolveReference(name, request.signal, (reference) => {\n if (!reference.purposes.includes('browser')) throw new Error('Profile secret alias is unavailable');\n if (!reference.allowedOrigins.includes(request.origin)) throw new Error('Profile secret origin is not allowed');\n });\n }\n\n resolveProxySecret(signal?: AbortSignal): Promise<string> {\n const name = this.snapshot.integration?.browser?.proxySecret;\n if (name === undefined) return Promise.reject(new Error('Profile proxy is not configured'));\n return this.resolveReference(name, signal, (reference) => {\n if (!reference.purposes.includes('proxy')) throw new Error('Profile secret alias is unavailable');\n });\n }\n\n private async resolveReference(\n name: string,\n requestSignal: AbortSignal | undefined,\n authorize: (reference: ProfileSecretReference) => void,\n ): Promise<string> {\n // Do not await ready here: a provider factory invoking this callback would\n // otherwise wait for itself. Browser creation may retain, but not invoke it.\n if (this.initializing) throw new Error('Profile secrets are unavailable during provider initialization');\n await this.ready();\n const snapshot = this.snapshot;\n const connection = this.connection;\n const reference = snapshot.integration?.secrets[name];\n if (!connection || !reference || !Object.hasOwn(snapshot.integration!.secrets, name)) {\n throw new Error('Profile secret alias is unavailable');\n }\n authorize(reference);\n const signal = requestSignal ? AbortSignal.any([snapshot.signal, requestSignal]) : snapshot.signal;\n if (signal.aborted) throw new Error(INVALIDATED);\n let value: string;\n try {\n value = await connection.resolveSecret(reference, signal);\n } catch {\n // Provider failures must not leak API responses, credential fields or secrets.\n throw new Error('Profile secret resolution failed');\n }\n if (signal.aborted || this.snapshot !== snapshot || this.connection !== connection) throw new Error(INVALIDATED);\n if (typeof value !== 'string' || value.length === 0) throw new Error('Profile secret field is unavailable');\n return value;\n }\n\n dispose(): Promise<void> {\n if (this.disposal) return this.disposal;\n this.disposed = true;\n this.invalidate();\n this.provider = undefined;\n this.disposal = (async () => {\n const results = await Promise.allSettled([...this.pending, this.retirement]);\n if (results.some((result) => result.status === 'rejected')) throw new Error('Profile runtime disposal failed');\n })();\n return this.disposal;\n }\n}\n\nexport function createProfileRuntime(options: ProfileRuntimeOptions): ProfileRuntime {\n return new SessionProfileRuntime(options);\n}\n\n/** Mounted in the scoped root services array, before dependent integration tools. */\nexport function createProfileRuntimePlugin(runtime: ProfileRuntime): (context: Context) => void {\n return (context) => {\n context.provide(PROFILE_RUNTIME_SERVICE, runtime);\n };\n}\n\nexport function requireProfileRuntime(context: Context): ProfileRuntime {\n const service = context.get(PROFILE_RUNTIME_SERVICE);\n if (!service) throw new Error('Profile runtime service is unavailable');\n return service;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-runtime': ProfileRuntime;\n }\n}\n","// @scaffold-generated\nimport type { ProfileIntegrationBinding } from '@agimon-ai/po-config/profiles';\nimport { type Context, Service } from '@deepseek-ai/cordis';\n\nimport { PROFILE_SECRETS_SERVICE } from '../../constants/profileSecrets';\nimport type { ProfileProviderFactory, ProfileSecretResolver } from '../profileRuntime/type';\nimport type { ProfileEnvSecretRequest, ProfileSecrets, ProfileSecretsOptions } from './type';\n\n/** Every failure is generic so callers never learn which alias, field or provider response failed. */\nconst UNAVAILABLE = 'Profile secrets are unavailable';\n\nclass HostProfileSecrets implements ProfileSecrets {\n private readonly providers = new Map<string, ProfileProviderFactory>();\n private generation = 0;\n\n constructor(private readonly options: ProfileSecretsOptions) {}\n\n registerProvider(provider: string, factory: ProfileProviderFactory): () => void {\n if (this.providers.has(provider)) throw new Error('Profile secrets provider is already registered');\n this.providers.set(provider, factory);\n return () => {\n if (this.providers.get(provider) === factory) this.providers.delete(provider);\n };\n }\n\n async resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>> {\n if (request.names.length === 0) return {};\n if (new Set(request.names).size !== request.names.length) throw new Error(UNAVAILABLE);\n let binding: ProfileIntegrationBinding | undefined;\n try {\n binding = await this.options.readBinding(request.cwd, request.profile, request.homeDirectory);\n } catch {\n throw new Error(UNAVAILABLE);\n }\n const factory = binding && this.providers.get(binding.provider);\n if (!binding || !factory) throw new Error(UNAVAILABLE);\n const references = request.names.map((name) => {\n const reference = Object.hasOwn(binding.secrets, name) ? binding.secrets[name] : undefined;\n if (!reference?.purposes.includes('env')) throw new Error(UNAVAILABLE);\n return [name, reference] as const;\n });\n\n const controller = new AbortController();\n const signal = request.signal ? AbortSignal.any([controller.signal, request.signal]) : controller.signal;\n let connection: ProfileSecretResolver | undefined;\n try {\n connection = await factory(binding, { profileName: request.profile, generation: ++this.generation, signal });\n const values: Record<string, string> = {};\n for (const [name, reference] of references) {\n const value = await connection.resolveSecret(reference, signal);\n if (signal.aborted || typeof value !== 'string' || value.length === 0) throw new Error(UNAVAILABLE);\n values[name] = value;\n }\n return values;\n } catch {\n throw new Error(UNAVAILABLE);\n } finally {\n controller.abort();\n try {\n await connection?.dispose();\n } catch {\n // Disposal failures are not secret-bearing, but the resolved values are still discarded.\n // oxlint-disable-next-line no-unsafe-finally\n throw new Error(UNAVAILABLE);\n }\n }\n }\n}\n\nexport function createProfileSecrets(options: ProfileSecretsOptions): ProfileSecrets {\n return new HostProfileSecrets(options);\n}\n\n/** Host-side env secret resolution for workflow run steps. Never registered as a model tool. */\nexport class ProfileSecretsService extends Service implements ProfileSecrets {\n constructor(\n context: Context,\n private readonly source: ProfileSecrets,\n ) {\n super(context, PROFILE_SECRETS_SERVICE);\n }\n\n registerProvider(provider: string, factory: ProfileProviderFactory): () => void {\n return this.source.registerProvider(provider, factory);\n }\n\n resolveEnv(request: ProfileEnvSecretRequest): Promise<Record<string, string>> {\n return this.source.resolveEnv(request);\n }\n}\n\n/** Include in the extension services array. The helper owns the child fiber. */\nexport function createProfileSecretsPlugin(source: ProfileSecrets): (context: Context) => void {\n return (context: Context): void => {\n new ProfileSecretsService(context, source);\n };\n}\n\nexport function requireProfileSecrets(context: Context): ProfileSecretsService {\n const service = context.get(PROFILE_SECRETS_SERVICE);\n if (!service) throw new Error('Profile secrets service is unavailable');\n return service;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/profile-secrets': ProfileSecretsService;\n }\n}\n","import type { AgentProfile } from '@agimon-ai/po-config/profiles';\n\nconst NONE = '(none)';\n\n/** Footer status key the cockpit's profile axis reads. */\ninterface SelectItem {\n value: string;\n label: string;\n description?: string;\n}\n\nexport const PROFILE_STATUS_KEY = 'po-profile';\n\n/** Identity this package registers voice capabilities under. */\nexport const PROFILE_SOURCE = '@agimon-ai/po-profile';\n\n/** The command a queued voice switch invokes, and the reload handoff kind it parks. */\nexport const PROFILE_COMMAND = 'profile';\n\n/**\n * The published axis content: the active profile's name, empty while\n * profiles exist with none active, and undefined to withhold the status so\n * the cockpit keeps the axis off the bar entirely.\n */\nexport function profileStatus(current: string | undefined, hasProfiles: boolean): string | undefined {\n if (current) return current;\n return hasProfiles ? '' : undefined;\n}\n\n/** Rows for the single-select profile picker. */\nexport function profileItems(profiles: AgentProfile[]): SelectItem[] {\n return profiles.map((profile) => ({\n value: profile.name,\n label: profile.name,\n description: profileDescription(profile),\n }));\n}\n\nexport function profileDescription(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return environmentKeys.length > 0 ? `${profile.persona} (env: ${environmentKeys.join(', ')})` : profile.persona;\n}\n\n/** Shown when the picked profile is already active. */\nexport function profileSummary(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n return [\n `Profile ${profile.name}`,\n `Persona: ${profile.persona}`,\n `Env: ${environmentKeys.join(', ') || NONE}`,\n 'Already loaded.',\n ].join('\\n');\n}\n\nexport function profileTitle(current?: string): string {\n return `Profile (current: ${current ?? NONE})`;\n}\n"],"mappings":";;;AAAA,MAAa,0BAA0B;;;ACCvC,MAAa,0BAA0B;;;ACYvC,MAAMA,gBAAc;AACpB,MAAM,cAAc;;AAGpB,IAAM,wBAAN,MAAsD;CAYvB;CAX7B,aAAqB,IAAI,gBAAgB;CACzC;CACA;CACA;CACA,aAAoC,QAAQ,QAAQ;CACpD,aAAoC,QAAQ,QAAQ;CACpD,0BAA2B,IAAI,IAAmB;CAClD,eAAuB;CACvB,WAAmB;CACnB;CAEA,YAAY,SAAiD;EAAhC,KAAA,UAAA;EAC3B,KAAK,WAAW,KAAK,QAAQ,QAAQ,aAAa,CAAC;CACrD;CAEA,QAAgB,aAAiC,YAA4C;EAC3F,MAAM,UAAU,gBAAgB,KAAA,IAAY,KAAA,IAAY,KAAK,QAAQ,YAAY,WAAW;EAC5F,MAAM,MAAM,gBAAgB,KAAA,IAAY,KAAA,IAAY,KAAK,QAAQ,UAAU,WAAW;EACtF,OAAO,OAAO,OAAO;GACnB,GAAI,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY;GACnD,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,cAAA,GAAaC,8BAAAA,oBAAAA,CAAoB,OAAO,EAAE;GAC7E,GAAI,QAAQ,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK,OAAO,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE;GAC9D;GACA,Q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