@apotech-os/support-kit 2.9.0 → 2.10.0

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.
package/dist/index.js CHANGED
@@ -2142,6 +2142,8 @@ var CREATE_AGENT_INPUT_NAME_UID = "0cb57453-7b02-49ce-875b-7ff079a5810d";
2142
2142
  var CREATE_AGENT_INPUT_MODEL_ID_UID = "f19f1c10-3145-482b-8c1d-6fd3576596ff";
2143
2143
  var CREATE_AGENT_INPUT_PROVIDER_UID = "0dd94db4-f31a-4cd2-b030-1b1a4da5b43e";
2144
2144
  var CREATE_AGENT_INPUT_SYSTEM_PROMPT_SNAPSHOT_UID = "d50f3810-b6fe-4c90-b69b-3e36ba502cdb";
2145
+ var CREATE_AGENT_INPUT_PROMPT_NAME_UID = "102d412a-3299-42a2-ac62-6f7c4155508d";
2146
+ var CREATE_AGENT_INPUT_PROMPT_LABEL_UID = "04f8eeba-2d0b-4814-8009-a4a3d1530760";
2145
2147
  var SET_DEFAULT_AGENT_INPUT_AGENT_ID_UID = "0686c615-63f8-49a1-b3c7-3542bac76cd6";
2146
2148
  var EXT_CHAT_INPUT_MESSAGES_UID = "874e4408-74c0-4188-b923-a0791da4d096";
2147
2149
  var EXT_CHAT_INPUT_MODEL_ID_UID = "d63f05b1-165d-45e0-9300-cabe5e22fa42";
@@ -2965,6 +2967,20 @@ function buildCreateAgentFunctionDef(config) {
2965
2967
  type: FieldType.TEXT,
2966
2968
  label: "System prompt snapshot",
2967
2969
  isNullable: true
2970
+ },
2971
+ {
2972
+ universalIdentifier: CREATE_AGENT_INPUT_PROMPT_NAME_UID,
2973
+ name: "promptName",
2974
+ type: FieldType.TEXT,
2975
+ label: "Prompt name",
2976
+ isNullable: true
2977
+ },
2978
+ {
2979
+ universalIdentifier: CREATE_AGENT_INPUT_PROMPT_LABEL_UID,
2980
+ name: "promptLabel",
2981
+ type: FieldType.TEXT,
2982
+ label: "Prompt label",
2983
+ isNullable: true
2968
2984
  }
2969
2985
  ]
2970
2986
  };
@@ -2977,14 +2993,19 @@ async function createAgentHandler(ctx, input) {
2977
2993
  if (!name) throw new ctx.NonRetriableError("name is required");
2978
2994
  const modelId = input?.modelId?.trim();
2979
2995
  if (!modelId) throw new ctx.NonRetriableError("modelId is required");
2980
- const created = await ctx.api.create("agent", {
2996
+ const base = {
2981
2997
  name,
2982
2998
  modelId,
2983
2999
  provider: input.provider?.trim() || DEFAULT_LLM_PROVIDER,
2984
3000
  status: "available",
2985
- promptName: PENDING_PROMPT_NAME,
2986
- ...input.systemPromptSnapshot?.trim() ? { systemPromptSnapshot: input.systemPromptSnapshot.trim() } : {}
2987
- });
3001
+ ...input.systemPromptSnapshot?.trim() ? { systemPromptSnapshot: input.systemPromptSnapshot.trim() } : {},
3002
+ ...input.promptLabel?.trim() ? { promptLabel: input.promptLabel.trim() } : {}
3003
+ };
3004
+ const promptName = input.promptName?.trim();
3005
+ if (promptName) {
3006
+ return toAgent(await ctx.api.create("agent", { ...base, promptName }));
3007
+ }
3008
+ const created = await ctx.api.create("agent", { ...base, promptName: PENDING_PROMPT_NAME });
2988
3009
  const withPromptName = await ctx.api.update("agent", created.id, { promptName: `agent/${created.id}` });
2989
3010
  return toAgent(withPromptName);
2990
3011
  }
@@ -3095,22 +3116,23 @@ function createSyncAgentPromptSnapshotHandler() {
3095
3116
  async function syncAgentPromptSnapshotHandler(ctx, input) {
3096
3117
  const promptName = input?.promptName?.trim();
3097
3118
  if (!promptName) throw new ctx.NonRetriableError("promptName is required");
3098
- const page = await ctx.api.list("agent", { filter: { promptName }, limit: 1 });
3099
- const record = page.items[0];
3100
- if (!record) return { updated: false };
3101
- const agent = toAgent(record);
3102
- try {
3103
- const ref = agent.promptVersion !== null ? { version: agent.promptVersion } : { label: agent.promptLabel ?? "production" };
3104
- const detail = await ctx.api.prompts.get(promptName, { ...ref, resolve: false });
3105
- if (detail.content === agent.systemPromptSnapshot) return { updated: false };
3106
- await ctx.api.update("agent", agent.id, { systemPromptSnapshot: detail.content });
3107
- return { updated: true };
3108
- } catch (error) {
3109
- ctx.logger.warn(
3110
- `sync-agent-prompt-snapshot: could not refresh "${promptName}" \u2014 GET /models keeps serving the previous snapshot (${String(error)})`
3111
- );
3112
- return { updated: false };
3119
+ const page = await ctx.api.list("agent", { filter: { promptName } });
3120
+ let updated = false;
3121
+ for (const record of page.items) {
3122
+ const agent = toAgent(record);
3123
+ try {
3124
+ const ref = agent.promptVersion !== null ? { version: agent.promptVersion } : { label: agent.promptLabel ?? "production" };
3125
+ const detail = await ctx.api.prompts.get(promptName, { ...ref, resolve: false });
3126
+ if (detail.content === agent.systemPromptSnapshot) continue;
3127
+ await ctx.api.update("agent", agent.id, { systemPromptSnapshot: detail.content });
3128
+ updated = true;
3129
+ } catch (error) {
3130
+ ctx.logger.warn(
3131
+ `sync-agent-prompt-snapshot: could not refresh "${promptName}" for agent ${agent.id} \u2014 GET /models keeps serving the previous snapshot (${String(error)})`
3132
+ );
3133
+ }
3113
3134
  }
3135
+ return { updated };
3114
3136
  }
3115
3137
 
3116
3138
  // src/functions/ext-models.ts
@@ -3894,16 +3916,8 @@ var FUNCTION_ASSEMBLY = [
3894
3916
  createHandler: () => createExtResponseComparisonHandler()
3895
3917
  }
3896
3918
  ];
3897
- function buildPromptsAllowlist(config) {
3898
- return [
3899
- `${config.promptPrefix}*`,
3900
- // Agent prompts are free text, conventionally `agent/<recordId>` (§3.7)
3901
- // — never promptPrefix-prefixed, so they need their own glob.
3902
- "agent/*",
3903
- // Company-wide by design (§3.8), resolved by bare NAME off the settings
3904
- // fields' own defaults — outside every audience prefix.
3905
- "shared/*"
3906
- ];
3919
+ function buildPromptsAllowlist() {
3920
+ return ["*"];
3907
3921
  }
3908
3922
  function dedupe(items, keyOf) {
3909
3923
  const seen = /* @__PURE__ */ new Map();
@@ -3920,7 +3934,7 @@ function buildMergeRole(config) {
3920
3934
  const refsExcluding = (excludedObjectKeys) => kitRecords.filter((record) => !excludedObjectKeys.includes(record.objectKey)).map((record) => targetRefFor(config.slug, record.objectKey));
3921
3935
  const kitReadRefs = refsExcluding(KIT_WRITE_ONLY_OBJECT_KEYS);
3922
3936
  const kitWriteRefs = refsExcluding(KIT_READ_ONLY_OBJECT_KEYS);
3923
- const kitPrompts = buildPromptsAllowlist(config);
3937
+ const kitPrompts = buildPromptsAllowlist();
3924
3938
  return (role) => ({
3925
3939
  ...role,
3926
3940
  reads: dedupe([...role.reads, ...kitReadRefs], (ref) => ref),