@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.cjs CHANGED
@@ -3848,6 +3848,8 @@ var CREATE_AGENT_INPUT_NAME_UID = "0cb57453-7b02-49ce-875b-7ff079a5810d";
3848
3848
  var CREATE_AGENT_INPUT_MODEL_ID_UID = "f19f1c10-3145-482b-8c1d-6fd3576596ff";
3849
3849
  var CREATE_AGENT_INPUT_PROVIDER_UID = "0dd94db4-f31a-4cd2-b030-1b1a4da5b43e";
3850
3850
  var CREATE_AGENT_INPUT_SYSTEM_PROMPT_SNAPSHOT_UID = "d50f3810-b6fe-4c90-b69b-3e36ba502cdb";
3851
+ var CREATE_AGENT_INPUT_PROMPT_NAME_UID = "102d412a-3299-42a2-ac62-6f7c4155508d";
3852
+ var CREATE_AGENT_INPUT_PROMPT_LABEL_UID = "04f8eeba-2d0b-4814-8009-a4a3d1530760";
3851
3853
  var SET_DEFAULT_AGENT_INPUT_AGENT_ID_UID = "0686c615-63f8-49a1-b3c7-3542bac76cd6";
3852
3854
  var EXT_CHAT_INPUT_MESSAGES_UID = "874e4408-74c0-4188-b923-a0791da4d096";
3853
3855
  var EXT_CHAT_INPUT_MODEL_ID_UID = "d63f05b1-165d-45e0-9300-cabe5e22fa42";
@@ -4671,6 +4673,20 @@ function buildCreateAgentFunctionDef(config) {
4671
4673
  type: appKit.FieldType.TEXT,
4672
4674
  label: "System prompt snapshot",
4673
4675
  isNullable: true
4676
+ },
4677
+ {
4678
+ universalIdentifier: CREATE_AGENT_INPUT_PROMPT_NAME_UID,
4679
+ name: "promptName",
4680
+ type: appKit.FieldType.TEXT,
4681
+ label: "Prompt name",
4682
+ isNullable: true
4683
+ },
4684
+ {
4685
+ universalIdentifier: CREATE_AGENT_INPUT_PROMPT_LABEL_UID,
4686
+ name: "promptLabel",
4687
+ type: appKit.FieldType.TEXT,
4688
+ label: "Prompt label",
4689
+ isNullable: true
4674
4690
  }
4675
4691
  ]
4676
4692
  };
@@ -4683,14 +4699,19 @@ async function createAgentHandler(ctx, input) {
4683
4699
  if (!name) throw new ctx.NonRetriableError("name is required");
4684
4700
  const modelId = input?.modelId?.trim();
4685
4701
  if (!modelId) throw new ctx.NonRetriableError("modelId is required");
4686
- const created = await ctx.api.create("agent", {
4702
+ const base = {
4687
4703
  name,
4688
4704
  modelId,
4689
4705
  provider: input.provider?.trim() || DEFAULT_LLM_PROVIDER,
4690
4706
  status: "available",
4691
- promptName: PENDING_PROMPT_NAME,
4692
- ...input.systemPromptSnapshot?.trim() ? { systemPromptSnapshot: input.systemPromptSnapshot.trim() } : {}
4693
- });
4707
+ ...input.systemPromptSnapshot?.trim() ? { systemPromptSnapshot: input.systemPromptSnapshot.trim() } : {},
4708
+ ...input.promptLabel?.trim() ? { promptLabel: input.promptLabel.trim() } : {}
4709
+ };
4710
+ const promptName = input.promptName?.trim();
4711
+ if (promptName) {
4712
+ return toAgent(await ctx.api.create("agent", { ...base, promptName }));
4713
+ }
4714
+ const created = await ctx.api.create("agent", { ...base, promptName: PENDING_PROMPT_NAME });
4694
4715
  const withPromptName = await ctx.api.update("agent", created.id, { promptName: `agent/${created.id}` });
4695
4716
  return toAgent(withPromptName);
4696
4717
  }
@@ -4801,22 +4822,23 @@ function createSyncAgentPromptSnapshotHandler() {
4801
4822
  async function syncAgentPromptSnapshotHandler(ctx, input) {
4802
4823
  const promptName = input?.promptName?.trim();
4803
4824
  if (!promptName) throw new ctx.NonRetriableError("promptName is required");
4804
- const page = await ctx.api.list("agent", { filter: { promptName }, limit: 1 });
4805
- const record = page.items[0];
4806
- if (!record) return { updated: false };
4807
- const agent = toAgent(record);
4808
- try {
4809
- const ref = agent.promptVersion !== null ? { version: agent.promptVersion } : { label: agent.promptLabel ?? "production" };
4810
- const detail = await ctx.api.prompts.get(promptName, { ...ref, resolve: false });
4811
- if (detail.content === agent.systemPromptSnapshot) return { updated: false };
4812
- await ctx.api.update("agent", agent.id, { systemPromptSnapshot: detail.content });
4813
- return { updated: true };
4814
- } catch (error) {
4815
- ctx.logger.warn(
4816
- `sync-agent-prompt-snapshot: could not refresh "${promptName}" \u2014 GET /models keeps serving the previous snapshot (${String(error)})`
4817
- );
4818
- return { updated: false };
4825
+ const page = await ctx.api.list("agent", { filter: { promptName } });
4826
+ let updated = false;
4827
+ for (const record of page.items) {
4828
+ const agent = toAgent(record);
4829
+ try {
4830
+ const ref = agent.promptVersion !== null ? { version: agent.promptVersion } : { label: agent.promptLabel ?? "production" };
4831
+ const detail = await ctx.api.prompts.get(promptName, { ...ref, resolve: false });
4832
+ if (detail.content === agent.systemPromptSnapshot) continue;
4833
+ await ctx.api.update("agent", agent.id, { systemPromptSnapshot: detail.content });
4834
+ updated = true;
4835
+ } catch (error) {
4836
+ ctx.logger.warn(
4837
+ `sync-agent-prompt-snapshot: could not refresh "${promptName}" for agent ${agent.id} \u2014 GET /models keeps serving the previous snapshot (${String(error)})`
4838
+ );
4839
+ }
4819
4840
  }
4841
+ return { updated };
4820
4842
  }
4821
4843
 
4822
4844
  // src/functions/ext-models.ts
@@ -5636,16 +5658,8 @@ var FUNCTION_ASSEMBLY = [
5636
5658
  createHandler: () => createExtResponseComparisonHandler()
5637
5659
  }
5638
5660
  ];
5639
- function buildPromptsAllowlist(config) {
5640
- return [
5641
- `${config.promptPrefix}*`,
5642
- // Agent prompts are free text, conventionally `agent/<recordId>` (§3.7)
5643
- // — never promptPrefix-prefixed, so they need their own glob.
5644
- "agent/*",
5645
- // Company-wide by design (§3.8), resolved by bare NAME off the settings
5646
- // fields' own defaults — outside every audience prefix.
5647
- "shared/*"
5648
- ];
5661
+ function buildPromptsAllowlist() {
5662
+ return ["*"];
5649
5663
  }
5650
5664
  function dedupe(items, keyOf) {
5651
5665
  const seen = /* @__PURE__ */ new Map();
@@ -5662,7 +5676,7 @@ function buildMergeRole(config) {
5662
5676
  const refsExcluding = (excludedObjectKeys) => kitRecords.filter((record) => !excludedObjectKeys.includes(record.objectKey)).map((record) => targetRefFor(config.slug, record.objectKey));
5663
5677
  const kitReadRefs = refsExcluding(KIT_WRITE_ONLY_OBJECT_KEYS);
5664
5678
  const kitWriteRefs = refsExcluding(KIT_READ_ONLY_OBJECT_KEYS);
5665
- const kitPrompts = buildPromptsAllowlist(config);
5679
+ const kitPrompts = buildPromptsAllowlist();
5666
5680
  return (role) => ({
5667
5681
  ...role,
5668
5682
  reads: dedupe([...role.reads, ...kitReadRefs], (ref) => ref),