@agent-native/core 0.24.10 → 0.26.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.
Files changed (53) hide show
  1. package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
  2. package/dist/agent/engine/ai-sdk-engine.js +2 -1
  3. package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
  4. package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
  5. package/dist/agent/engine/anthropic-engine.js +2 -1
  6. package/dist/agent/engine/anthropic-engine.js.map +1 -1
  7. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  8. package/dist/agent/engine/builder-engine.js +31 -12
  9. package/dist/agent/engine/builder-engine.js.map +1 -1
  10. package/dist/agent/engine/output-tokens.d.ts +8 -0
  11. package/dist/agent/engine/output-tokens.d.ts.map +1 -0
  12. package/dist/agent/engine/output-tokens.js +60 -0
  13. package/dist/agent/engine/output-tokens.js.map +1 -0
  14. package/dist/agent/production-agent.d.ts +2 -1
  15. package/dist/agent/production-agent.d.ts.map +1 -1
  16. package/dist/agent/production-agent.js +66 -25
  17. package/dist/agent/production-agent.js.map +1 -1
  18. package/dist/client/AssistantChat.d.ts.map +1 -1
  19. package/dist/client/AssistantChat.js +3 -1
  20. package/dist/client/AssistantChat.js.map +1 -1
  21. package/dist/client/composer/ComposerPlusMenu.d.ts.map +1 -1
  22. package/dist/client/composer/ComposerPlusMenu.js +138 -5
  23. package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
  24. package/dist/client/index.d.ts +3 -1
  25. package/dist/client/index.d.ts.map +1 -1
  26. package/dist/client/index.js +3 -1
  27. package/dist/client/index.js.map +1 -1
  28. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  29. package/dist/client/resources/ResourcesPanel.js +124 -8
  30. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  31. package/dist/client/use-external-value.d.ts +17 -0
  32. package/dist/client/use-external-value.d.ts.map +1 -0
  33. package/dist/client/use-external-value.js +29 -0
  34. package/dist/client/use-external-value.js.map +1 -0
  35. package/dist/collab/client.d.ts +18 -0
  36. package/dist/collab/client.d.ts.map +1 -1
  37. package/dist/collab/client.js +81 -2
  38. package/dist/collab/client.js.map +1 -1
  39. package/dist/scripts/docs/search.d.ts.map +1 -1
  40. package/dist/scripts/docs/search.js +52 -6
  41. package/dist/scripts/docs/search.js.map +1 -1
  42. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  43. package/dist/server/agent-chat-plugin.js +87 -79
  44. package/dist/server/agent-chat-plugin.js.map +1 -1
  45. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  46. package/dist/server/core-routes-plugin.js +6 -6
  47. package/dist/server/core-routes-plugin.js.map +1 -1
  48. package/dist/server/create-server.d.ts.map +1 -1
  49. package/dist/server/create-server.js +5 -1
  50. package/dist/server/create-server.js.map +1 -1
  51. package/dist/server/onboarding-html.js +1 -1
  52. package/dist/server/onboarding-html.js.map +1 -1
  53. package/package.json +1 -2
@@ -37,6 +37,14 @@ async function lazyFs() {
37
37
  return _fs;
38
38
  }
39
39
  const SHARED_PROMPT_RESOURCE_MAX_CHARS = 30_000;
40
+ const COMPACT_PROMPT_RESOURCE_MAX_CHARS = 12_000;
41
+ const MAX_ACTION_SUMMARY_DESCRIPTION_CHARS = 140;
42
+ function compactPromptLine(value, maxChars) {
43
+ const line = value.replace(/\s+/g, " ").trim();
44
+ if (line.length <= maxChars)
45
+ return line;
46
+ return `${line.slice(0, maxChars - 1)}…`;
47
+ }
40
48
  const SHARED_RESOURCE_INDEX_LIMIT = 40;
41
49
  function normalizeResourcePathForPrompt(path) {
42
50
  return path.replace(/^\/+/, "").trim();
@@ -44,18 +52,20 @@ function normalizeResourcePathForPrompt(path) {
44
52
  function escapeXmlAttribute(value) {
45
53
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
46
54
  }
47
- function truncatePromptResourceContent(content, path, maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS) {
55
+ function truncatePromptResourceContent(content, path, maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS, readHint) {
48
56
  const trimmed = content.trim();
49
57
  if (trimmed.length <= maxChars)
50
58
  return trimmed;
51
59
  const omitted = trimmed.length - maxChars;
52
- return `${trimmed.slice(0, maxChars)}\n\n[Resource ${path} truncated after ${maxChars.toLocaleString()} characters; ${omitted.toLocaleString()} characters omitted. Use resource-read --path "${path}" with the resource's scope for the full content.]`;
60
+ const hint = readHint ??
61
+ `Use resource-read --path "${path}" with the resource's scope for the full content.`;
62
+ return `${trimmed.slice(0, maxChars)}\n\n[Resource ${path} truncated after ${maxChars.toLocaleString()} characters; ${omitted.toLocaleString()} characters omitted. ${hint}]`;
53
63
  }
54
64
  function promptResourceBlock(input) {
55
65
  const normalizedPath = input.path
56
66
  ? normalizeResourcePathForPrompt(input.path)
57
67
  : undefined;
58
- const content = truncatePromptResourceContent(input.content, normalizedPath ?? input.name, input.maxChars);
68
+ const content = truncatePromptResourceContent(input.content, normalizedPath ?? input.name, input.maxChars, input.readHint);
59
69
  if (!content)
60
70
  return null;
61
71
  const pathAttr = normalizedPath
@@ -112,7 +122,7 @@ function resourceScopeForOwner(owner, currentOwner) {
112
122
  return "personal";
113
123
  return "resource";
114
124
  }
115
- async function loadAgentsResourceForPrompt(owner, scope) {
125
+ async function loadAgentsResourceForPrompt(owner, scope, maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS) {
116
126
  try {
117
127
  const agents = await resourceGetByPath(owner, "AGENTS.md");
118
128
  if (!agents?.content?.trim())
@@ -122,13 +132,14 @@ async function loadAgentsResourceForPrompt(owner, scope) {
122
132
  scope,
123
133
  path: "AGENTS.md",
124
134
  content: agents.content,
135
+ maxChars,
125
136
  });
126
137
  }
127
138
  catch {
128
139
  return null;
129
140
  }
130
141
  }
131
- async function loadInstructionResourcesForPrompt(owner, scope) {
142
+ async function loadInstructionResourcesForPrompt(owner, scope, maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS) {
132
143
  try {
133
144
  const resources = await resourceList(owner, "instructions/");
134
145
  const blocks = [];
@@ -144,6 +155,7 @@ async function loadInstructionResourcesForPrompt(owner, scope) {
144
155
  scope,
145
156
  path: resource.path,
146
157
  content: full.content,
158
+ maxChars,
147
159
  });
148
160
  if (block)
149
161
  blocks.push(block);
@@ -2019,17 +2031,38 @@ const DEFAULT_SYSTEM_PROMPT = PROD_FRAMEWORK_PROMPT;
2019
2031
  export async function loadResourcesForPrompt(owner, compact = false, selfAppId) {
2020
2032
  await ensurePersonalDefaults(owner);
2021
2033
  const sections = [];
2034
+ const promptResourceMaxChars = compact
2035
+ ? COMPACT_PROMPT_RESOURCE_MAX_CHARS
2036
+ : SHARED_PROMPT_RESOURCE_MAX_CHARS;
2022
2037
  // 1. Workspace AGENTS.md + skills merged into the template bundle.
2023
2038
  try {
2024
2039
  const { loadAgentsBundle, generateSkillsPromptBlock } = await import("./agents-bundle.js");
2025
2040
  const bundle = await loadAgentsBundle();
2026
2041
  // Workspace-core AGENTS.md (enterprise-wide instructions), if present.
2027
2042
  if (bundle.workspaceAgentsMd && bundle.workspaceAgentsMd.trim()) {
2028
- sections.push(`<resource name="AGENTS.md" scope="workspace">\n${bundle.workspaceAgentsMd.trim()}\n</resource>`);
2043
+ const block = promptResourceBlock({
2044
+ name: "AGENTS.md",
2045
+ scope: "workspace",
2046
+ path: "AGENTS.md",
2047
+ content: bundle.workspaceAgentsMd,
2048
+ maxChars: promptResourceMaxChars,
2049
+ readHint: 'Use docs-search --slug "agents-workspace" to read the full workspace AGENTS.md.',
2050
+ });
2051
+ if (block)
2052
+ sections.push(block);
2029
2053
  }
2030
2054
  // 2. Template AGENTS.md — always included (critical template instructions).
2031
2055
  if (bundle.agentsMd.trim()) {
2032
- sections.push(`<resource name="AGENTS.md" scope="template">\n${bundle.agentsMd.trim()}\n</resource>`);
2056
+ const block = promptResourceBlock({
2057
+ name: "AGENTS.md",
2058
+ scope: "template",
2059
+ path: "AGENTS.md",
2060
+ content: bundle.agentsMd,
2061
+ maxChars: promptResourceMaxChars,
2062
+ readHint: 'Use docs-search --slug "agents-template" to read the full template AGENTS.md.',
2063
+ });
2064
+ if (block)
2065
+ sections.push(block);
2033
2066
  }
2034
2067
  // In compact mode, skip the full skills block — the agent can use
2035
2068
  // `docs-search` to find skills when it needs them.
@@ -2048,23 +2081,23 @@ export async function loadResourcesForPrompt(owner, compact = false, selfAppId)
2048
2081
  catch { }
2049
2082
  // 3. Runtime workspace resources from SQL. These are global defaults
2050
2083
  // inherited by every app in the workspace, not copied into app scopes.
2051
- const workspaceAgents = await loadAgentsResourceForPrompt(WORKSPACE_OWNER, "workspace");
2084
+ const workspaceAgents = await loadAgentsResourceForPrompt(WORKSPACE_OWNER, "workspace", promptResourceMaxChars);
2052
2085
  if (workspaceAgents)
2053
2086
  sections.push(workspaceAgents);
2054
- sections.push(...(await loadInstructionResourcesForPrompt(WORKSPACE_OWNER, "workspace-instruction")));
2087
+ sections.push(...(await loadInstructionResourcesForPrompt(WORKSPACE_OWNER, "workspace-instruction", promptResourceMaxChars)));
2055
2088
  // 4. Runtime shared/app/org resources from SQL. These come after workspace
2056
2089
  // defaults so app/team-specific guidance can override or narrow them.
2057
- const sharedAgents = await loadAgentsResourceForPrompt(SHARED_OWNER, "shared");
2090
+ const sharedAgents = await loadAgentsResourceForPrompt(SHARED_OWNER, "shared", promptResourceMaxChars);
2058
2091
  if (sharedAgents)
2059
2092
  sections.push(sharedAgents);
2060
- sections.push(...(await loadInstructionResourcesForPrompt(SHARED_OWNER, "shared-instruction")));
2093
+ sections.push(...(await loadInstructionResourcesForPrompt(SHARED_OWNER, "shared-instruction", promptResourceMaxChars)));
2061
2094
  // 5. Personal SQL resources. These come last in the instruction stack so a
2062
2095
  // user can narrow or override organization/app and workspace defaults.
2063
2096
  if (owner !== SHARED_OWNER && owner !== WORKSPACE_OWNER) {
2064
- const personalAgents = await loadAgentsResourceForPrompt(owner, "personal");
2097
+ const personalAgents = await loadAgentsResourceForPrompt(owner, "personal", promptResourceMaxChars);
2065
2098
  if (personalAgents)
2066
2099
  sections.push(personalAgents);
2067
- sections.push(...(await loadInstructionResourcesForPrompt(owner, "personal-instruction")));
2100
+ sections.push(...(await loadInstructionResourcesForPrompt(owner, "personal-instruction", promptResourceMaxChars)));
2068
2101
  }
2069
2102
  const resourceSkillsBlock = await loadResourceSkillsPromptBlock(owner);
2070
2103
  if (resourceSkillsBlock)
@@ -2154,84 +2187,59 @@ const DEFAULT_DEV_PROMPT = "";
2154
2187
  function generateActionsPrompt(registry, mode = "tool") {
2155
2188
  if (!registry || Object.keys(registry).length === 0)
2156
2189
  return "";
2157
- const lines = Object.entries(registry).map(([name, entry]) => {
2190
+ const actionEntries = Object.entries(registry);
2191
+ if (mode === "tool") {
2192
+ const summaryLines = actionEntries.map(([name, entry]) => {
2193
+ const desc = compactPromptLine(entry.tool.description, MAX_ACTION_SUMMARY_DESCRIPTION_CHARS);
2194
+ return `- \`${name}\` — ${desc}`;
2195
+ });
2196
+ return `\n\n## Available Actions
2197
+
2198
+ **Use these actions directly as tool calls.** They handle database access, validation, and business logic internally. The native tool schemas contain the full parameter details.
2199
+
2200
+ ${summaryLines.join("\n")}`;
2201
+ }
2202
+ const lines = actionEntries.map(([name, entry]) => {
2158
2203
  const desc = entry.tool.description;
2159
2204
  const params = entry.tool.parameters?.properties;
2160
2205
  const requiredFields = new Set(entry.tool.parameters?.required ?? []);
2161
- if (mode === "cli") {
2162
- // CLI mode: emit `pnpm action <name> --required <type> [--optional <type>]`
2163
- if (!params || Object.keys(params).length === 0) {
2164
- return `- \`pnpm action ${name}\` — ${desc}`;
2206
+ // CLI mode: emit `pnpm action <name> --required <type> [--optional <type>]`
2207
+ if (!params || Object.keys(params).length === 0) {
2208
+ return `- \`pnpm action ${name}\` ${desc}`;
2209
+ }
2210
+ const entries = Object.entries(params);
2211
+ // Required first (alphabetical), then optional (alphabetical)
2212
+ entries.sort(([a], [b]) => {
2213
+ const ar = requiredFields.has(a) ? 0 : 1;
2214
+ const br = requiredFields.has(b) ? 0 : 1;
2215
+ if (ar !== br)
2216
+ return ar - br;
2217
+ return a.localeCompare(b);
2218
+ });
2219
+ const required = [];
2220
+ const optional = [];
2221
+ const requiredNames = [];
2222
+ for (const [k, v] of entries) {
2223
+ const type = v.type ?? "any";
2224
+ const flag = `--${k} <${type}>`;
2225
+ if (requiredFields.has(k)) {
2226
+ required.push(flag);
2227
+ requiredNames.push(`--${k}`);
2165
2228
  }
2166
- const entries = Object.entries(params);
2167
- // Required first (alphabetical), then optional (alphabetical)
2168
- entries.sort(([a], [b]) => {
2169
- const ar = requiredFields.has(a) ? 0 : 1;
2170
- const br = requiredFields.has(b) ? 0 : 1;
2171
- if (ar !== br)
2172
- return ar - br;
2173
- return a.localeCompare(b);
2174
- });
2175
- const required = [];
2176
- const optional = [];
2177
- const requiredNames = [];
2178
- for (const [k, v] of entries) {
2179
- const type = v.type ?? "any";
2180
- const flag = `--${k} <${type}>`;
2181
- if (requiredFields.has(k)) {
2182
- required.push(flag);
2183
- requiredNames.push(`--${k}`);
2184
- }
2185
- else {
2186
- optional.push(`[${flag}]`);
2187
- }
2229
+ else {
2230
+ optional.push(`[${flag}]`);
2188
2231
  }
2189
- const cmd = ["pnpm action " + name, ...required, ...optional].join(" ");
2190
- const requiredNote = requiredNames.length > 0
2191
- ? ` Required: ${requiredNames.join(", ")}.`
2192
- : "";
2193
- return `- \`${cmd}\` — ${desc}.${requiredNote}`;
2194
2232
  }
2195
- // tool mode (production / native tool calls)
2196
- if (params) {
2197
- // Order required params first, then optional. Mark required with "*"
2198
- // and include type + description so the agent knows exactly how to call.
2199
- const entries = Object.entries(params);
2200
- entries.sort(([a], [b]) => {
2201
- const ar = requiredFields.has(a) ? 0 : 1;
2202
- const br = requiredFields.has(b) ? 0 : 1;
2203
- if (ar !== br)
2204
- return ar - br;
2205
- return a.localeCompare(b);
2206
- });
2207
- const paramList = entries
2208
- .map(([k, v]) => {
2209
- const isRequired = requiredFields.has(k);
2210
- const type = v.type ?? "any";
2211
- const marker = isRequired ? "*" : "?";
2212
- const descPart = v.description ? ` — ${v.description}` : "";
2213
- return `${k}${marker}: ${type}${descPart}`;
2214
- })
2215
- .join("; ");
2216
- return `- \`${name}\`(${paramList}) — ${desc}`;
2217
- }
2218
- return `- \`${name}\`() — ${desc}`;
2233
+ const cmd = ["pnpm action " + name, ...required, ...optional].join(" ");
2234
+ const requiredNote = requiredNames.length > 0 ? ` Required: ${requiredNames.join(", ")}.` : "";
2235
+ return `- \`${cmd}\` ${desc}.${requiredNote}`;
2219
2236
  });
2220
- if (mode === "cli") {
2221
- return `\n\n## Available Actions
2237
+ return `\n\n## Available Actions
2222
2238
 
2223
2239
  **These template actions are NOT exposed as direct tools in dev mode. To run any of them, use the \`bash\` tool with the exact command shown below.** Example: \`bash(command="pnpm action add-slide --deckId abc --content 'Hello'")\`.
2224
2240
 
2225
2241
  Do NOT try to call these by name as if they were tools — they will not exist in your tool list. Always go through \`bash\`.
2226
2242
 
2227
- ${lines.join("\n")}`;
2228
- }
2229
- return `\n\n## Available Actions
2230
-
2231
- **Use these actions directly as tool calls.** They are your primary tools — they handle database access, validation, and business logic internally. Prefer these over lower-level tools like \`web-request\` or \`db-query\`.
2232
-
2233
- Parameter notation: \`name*\` = required, \`name?\` = optional. Pass parameters as a JSON object.
2234
-
2235
2243
  ${lines.join("\n")}`;
2236
2244
  }
2237
2245
  /**