@apotech-os/support-kit 2.6.0 → 2.7.1

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
@@ -2383,12 +2383,12 @@ function buildSupportKitRecords(slug) {
2383
2383
  // src/settings/fields.ts
2384
2384
  var SUPPORT_KIT_SETTINGS_FIELDS = [
2385
2385
  // Source
2386
- {
2387
- key: "gorgiasConnectionId",
2388
- type: "string",
2389
- label: "Gorgias connection",
2390
- default: ""
2391
- },
2386
+ // NO `gorgiasConnectionId`: every Gorgias call in this kit is
2387
+ // `ctx.api.integrations.run('gorgias', …)` with no `connectionId`, so the
2388
+ // platform resolves the instance's default connection. A settings key here
2389
+ // would be written by an operator and read by nobody — see the Source
2390
+ // section of `ui/settings/settings-page.tsx`, which STATES the resolved
2391
+ // connection instead of pretending to choose it.
2392
2392
  {
2393
2393
  key: "sourceViewId",
2394
2394
  type: "string",
@@ -3779,6 +3779,7 @@ var GRAPH_DRY_RUN_INPUT_TICKET_ID_UID = "5861e7be-3a28-4852-874c-1c14e82d4b35";
3779
3779
  var GRAPH_DRY_RUN_INPUT_CATEGORY_ID_UID = "c47b8b57-6f7a-47d7-a9d1-a18fbf71a0f0";
3780
3780
  var GRAPH_DRY_RUN_INPUT_AGENT_ID_UID = "95d38506-bc22-4f91-ad43-797ff7b54f48";
3781
3781
  var GRAPH_DRY_RUN_INPUT_OVERRIDES_UID = "306a4f7d-db5d-4144-a6bd-865889e152e2";
3782
+ var GRAPH_DRY_RUN_INPUT_INLINE_TICKET_UID = "2abcc895-2751-4944-b527-78bc4604eed0";
3782
3783
  var TEST_AGENTS_INPUT_VIEW_ID_UID = "20227a8f-95d8-4c20-a9cd-eccb0ce39e3e";
3783
3784
  var TEST_AGENTS_INPUT_TICKET_IDS_UID = "7d27acff-b558-4783-a3ac-722f676b71a7";
3784
3785
  var TEST_AGENTS_INPUT_AGENT_ID_UID = "ea12d731-708b-4fcc-9ebb-6c4e0d04a60e";
@@ -4060,13 +4061,48 @@ function applyOverrides(profile, overrides) {
4060
4061
  function forcedClassification(tagName) {
4061
4062
  return { category: tagName, confidence: "high", reasoning: "operator: cat\xE9gorie forc\xE9e", isFallback: false, conversationOver: false };
4062
4063
  }
4064
+ var INLINE_TICKET_ID = "ticket-saisi";
4065
+ function createInlineConversationPort(ticket, now) {
4066
+ const conversation = {
4067
+ ref: { id: INLINE_TICKET_ID, channel: "gorgias" },
4068
+ subject: ticket.subject?.trim() ? ticket.subject.trim() : null,
4069
+ messages: [{ role: "user", content: ticket.body }],
4070
+ customer: { name: null, email: null, orderContext: null },
4071
+ isClosed: false,
4072
+ lastMessageAt: now,
4073
+ messageCount: 1,
4074
+ // No agent ever answered a ticket that was just typed: `null` is the
4075
+ // truth, and it is also what keeps `not_customer_turn` from holding the
4076
+ // run before a single node has looked at the text.
4077
+ lastAgentReplyAt: null,
4078
+ hasCustomerAttachment: false,
4079
+ // `sourceChannel`, NOT `ref.channel`: the latter names the ADAPTER
4080
+ // (gorgias) while every channel guardrail and the style prompt read this
4081
+ // one (`domain/conversation.ts`).
4082
+ sourceChannel: ticket.channel ?? "email"
4083
+ };
4084
+ return {
4085
+ listPending: async () => [],
4086
+ read: async () => conversation
4087
+ };
4088
+ }
4063
4089
  function buildGraphDryRunFunctionDef(config) {
4064
4090
  return {
4065
4091
  universalIdentifier: identifierFor(config, "graph-dry-run"),
4066
4092
  name: "graph-dry-run",
4067
4093
  trigger: { type: "uiInvoke", minRole: "EDITOR" },
4068
4094
  input: [
4069
- { universalIdentifier: GRAPH_DRY_RUN_INPUT_TICKET_ID_UID, name: "ticketId", type: appKit.FieldType.TEXT, label: "Ticket id", isNullable: false },
4095
+ // Nullable since the pasted-ticket mode: the handler enforces "exactly
4096
+ // one of ticketId/inlineTicket", which a per-field flag cannot express.
4097
+ { universalIdentifier: GRAPH_DRY_RUN_INPUT_TICKET_ID_UID, name: "ticketId", type: appKit.FieldType.TEXT, label: "Ticket id", isNullable: true },
4098
+ {
4099
+ universalIdentifier: GRAPH_DRY_RUN_INPUT_INLINE_TICKET_UID,
4100
+ name: "inlineTicket",
4101
+ type: appKit.FieldType.JSON,
4102
+ label: "Inline ticket",
4103
+ description: "{body, subject?, channel?} \u2014 replays a typed-in ticket instead of reading one from Gorgias.",
4104
+ isNullable: true
4105
+ },
4070
4106
  { universalIdentifier: GRAPH_DRY_RUN_INPUT_AGENT_ID_UID, name: "agentId", type: appKit.FieldType.TEXT, label: "Agent id", isNullable: true },
4071
4107
  { universalIdentifier: GRAPH_DRY_RUN_INPUT_CATEGORY_ID_UID, name: "categoryId", type: appKit.FieldType.TEXT, label: "Category id", isNullable: true },
4072
4108
  {
@@ -4085,7 +4121,10 @@ function createGraphDryRunHandler(config) {
4085
4121
  }
4086
4122
  async function graphDryRunHandler(ctx, config, input) {
4087
4123
  const ticketId = input?.ticketId?.trim();
4088
- if (!ticketId) throw new ctx.NonRetriableError("ticketId is required");
4124
+ const inlineBody = input?.inlineTicket?.body?.trim();
4125
+ if (ticketId && inlineBody) throw new ctx.NonRetriableError("Provide either ticketId or inlineTicket, not both");
4126
+ if (!ticketId && !inlineBody) throw new ctx.NonRetriableError("ticketId or inlineTicket.body is required");
4127
+ const inlineTicket = inlineBody ? { ...input.inlineTicket, body: inlineBody } : null;
4089
4128
  const settings = await ctx.api.settings.get();
4090
4129
  const issues = validateSettings(settings);
4091
4130
  if (issues.length > 0) {
@@ -4098,13 +4137,13 @@ async function graphDryRunHandler(ctx, config, input) {
4098
4137
  const baseProfile = settingsToProfile(settings, buildPromptsTable(config, draftPromptRefFor(agent, config)));
4099
4138
  const profile = applyOverrides(baseProfile, input.overrides ?? {});
4100
4139
  const realPorts = buildTicketPorts(ctx);
4101
- const ref = { id: ticketId, channel: "gorgias" };
4140
+ const ref = { id: inlineTicket ? INLINE_TICKET_ID : ticketId, channel: "gorgias" };
4102
4141
  const budget = createBudget({ signal: AbortSignal.timeout(DRY_RUN_DEADLINE_MS), maxToolCalls: profile.nodes.draft?.maxToolCalls ?? DEFAULT_MAX_TOOL_CALLS2 });
4103
4142
  const base = {
4104
4143
  ref,
4105
4144
  profile,
4106
4145
  ports: {
4107
- conversation: realPorts.conversation,
4146
+ conversation: inlineTicket ? createInlineConversationPort(inlineTicket, realPorts.clock.now()) : realPorts.conversation,
4108
4147
  reply: realPorts.reply,
4109
4148
  llm: realPorts.llm,
4110
4149
  prompt: realPorts.prompt,
@@ -4535,6 +4574,12 @@ async function readClaimedView(ctx, appSlug) {
4535
4574
  async function listGorgiasViewsHandler(ctx, config, input) {
4536
4575
  const rawViews = await ctx.api.integrations.run("gorgias", "listViews", {});
4537
4576
  const views = rawViews.views.map((v) => ({ id: String(v.id), name: v.name }));
4577
+ let connections;
4578
+ try {
4579
+ connections = await ctx.api.integrations.list("gorgias");
4580
+ } catch {
4581
+ connections = null;
4582
+ }
4538
4583
  const candidateSlugs = (input.checkAppSlugs ?? []).filter((slug) => slug && slug !== config.slug);
4539
4584
  const claimedByViewId = /* @__PURE__ */ new Map();
4540
4585
  const uncheckedAppSlugs = [];
@@ -4551,7 +4596,8 @@ async function listGorgiasViewsHandler(ctx, config, input) {
4551
4596
  }
4552
4597
  return {
4553
4598
  views: views.map((v) => ({ id: v.id, name: v.name, claimedByAppSlugs: claimedByViewId.get(v.id) ?? [] })),
4554
- uncheckedAppSlugs
4599
+ uncheckedAppSlugs,
4600
+ connections
4555
4601
  };
4556
4602
  }
4557
4603
  var PENDING_PROMPT_NAME = "agent/pending";