@agent-native/core 0.157.9 → 0.157.11

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 (114) hide show
  1. package/corpus/templates/analytics/scripts/first-party-analytics-postgres-retention-dry-run.sql +5 -2
  2. package/corpus/templates/analytics/server/lib/first-party-analytics-backend.ts +3 -1
  3. package/corpus/templates/analytics/server/lib/first-party-analytics-purge.ts +18 -6
  4. package/corpus/templates/analytics/server/plugins/db.ts +139 -0
  5. package/corpus/templates/slides/AGENTS.md +14 -10
  6. package/corpus/templates/slides/actions/export-pptx.ts +1215 -94
  7. package/corpus/templates/slides/actions/import-file.ts +16 -1
  8. package/corpus/templates/slides/actions/import-pptx.ts +61 -43
  9. package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +222 -29
  10. package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +71 -0
  11. package/corpus/templates/slides/app/global.css +19 -1
  12. package/corpus/templates/slides/app/lib/export-google-slides-client.ts +44 -5
  13. package/corpus/templates/slides/app/lib/export-pdf-client.ts +13 -6
  14. package/corpus/templates/slides/app/lib/export-pptx-client.ts +556 -25
  15. package/corpus/templates/slides/app/pages/DeckEditor.tsx +18 -1
  16. package/corpus/templates/slides/server/handlers/import/html-converter.ts +1176 -26
  17. package/corpus/templates/slides/server/handlers/import/pdf-fidelity-parser.ts +13 -0
  18. package/corpus/templates/slides/server/handlers/import/pptx-assets.ts +24 -0
  19. package/corpus/templates/slides/server/routes/api/exports/google-slides.post.ts +12 -4
  20. package/corpus/templates/slides/shared/aspect-ratios.ts +13 -1
  21. package/dist/agent/harness/migrations.js +24 -3
  22. package/dist/agent/production-agent.js +11 -0
  23. package/dist/agent/run-loop-with-resume.js +21 -4
  24. package/dist/automations/service.d.ts +6 -0
  25. package/dist/automations/service.js +35 -0
  26. package/dist/cli/code-agent-connector.d.ts +4 -1
  27. package/dist/cli/code-agent-connector.js +154 -23
  28. package/dist/cli/code-agent-executor.js +255 -13
  29. package/dist/cli/code-agent-runs.d.ts +1 -0
  30. package/dist/cli/code-agent-runs.js +2 -1
  31. package/dist/cli/portal-workspace.d.ts +49 -0
  32. package/dist/cli/portal-workspace.js +320 -0
  33. package/dist/client/AssistantChat.d.ts +1 -1
  34. package/dist/client/AssistantChat.js +39 -61
  35. package/dist/client/ConnectBuilderCard.js +33 -5
  36. package/dist/client/agent-chat-adapter.js +4 -0
  37. package/dist/client/analytics-platform.d.ts +2 -0
  38. package/dist/client/analytics-platform.js +12 -0
  39. package/dist/client/analytics.d.ts +3 -0
  40. package/dist/client/analytics.js +10 -1
  41. package/dist/client/chat/index.d.ts +1 -0
  42. package/dist/client/chat/index.js +1 -0
  43. package/dist/client/chat/run-recovery.d.ts +2 -1
  44. package/dist/client/chat/run-recovery.js +2 -2
  45. package/dist/client/chat-first/apps-rail.d.ts +1 -1
  46. package/dist/client/chat-first/apps-rail.js +11 -11
  47. package/dist/client/chat-first/surface-tabs.d.ts +1 -1
  48. package/dist/client/chat-first/surface-tabs.js +38 -36
  49. package/dist/client/chat-first/types.d.ts +5 -0
  50. package/dist/client/chat-first.d.ts +1 -1
  51. package/dist/client/chat-first.js +4 -4
  52. package/dist/client/desktop-local-code-change.d.ts +10 -0
  53. package/dist/client/desktop-local-code-change.js +16 -0
  54. package/dist/client/index.d.ts +1 -0
  55. package/dist/client/index.js +1 -0
  56. package/dist/client/observability/ThumbsFeedback.js +21 -7
  57. package/dist/client/terminal/AgentTerminal.d.ts +9 -1
  58. package/dist/client/terminal/AgentTerminal.js +38 -3
  59. package/dist/client/terminal/index.d.ts +1 -1
  60. package/dist/client/terminal/index.js +1 -1
  61. package/dist/client/track.js +9 -1
  62. package/dist/client/use-action.js +3 -0
  63. package/dist/collab/awareness.d.ts +2 -2
  64. package/dist/collab/struct-routes.d.ts +1 -1
  65. package/dist/db/client.js +1 -0
  66. package/dist/deploy/build.js +1 -1
  67. package/dist/ingestion/pptx.d.ts +78 -0
  68. package/dist/ingestion/pptx.js +991 -107
  69. package/dist/integrations/index.d.ts +3 -3
  70. package/dist/integrations/index.js +2 -2
  71. package/dist/integrations/plugin.js +95 -6
  72. package/dist/integrations/remote-commands-store.d.ts +5 -0
  73. package/dist/integrations/remote-commands-store.js +63 -22
  74. package/dist/integrations/remote-devices-store.d.ts +2 -1
  75. package/dist/integrations/remote-devices-store.js +46 -0
  76. package/dist/integrations/remote-types.d.ts +20 -0
  77. package/dist/jobs/actions/list-recurring-jobs.d.ts +3 -0
  78. package/dist/jobs/actions/list-recurring-jobs.js +5 -1
  79. package/dist/jobs/frontmatter.d.ts +16 -0
  80. package/dist/jobs/frontmatter.js +53 -0
  81. package/dist/jobs/remote-execution.d.ts +42 -0
  82. package/dist/jobs/remote-execution.js +287 -0
  83. package/dist/jobs/scheduler.js +102 -3
  84. package/dist/jobs/tools.js +50 -3
  85. package/dist/notifications/routes.d.ts +4 -4
  86. package/dist/observability/routes.d.ts +5 -5
  87. package/dist/provider-api/actions/custom-provider-registration.d.ts +9 -9
  88. package/dist/provider-api/actions/provider-api.d.ts +14 -14
  89. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  90. package/dist/resources/handlers.d.ts +1 -1
  91. package/dist/secrets/routes.d.ts +9 -9
  92. package/dist/server/action-routes.js +4 -2
  93. package/dist/server/agent-chat-plugin.js +6 -0
  94. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  95. package/dist/server/agent-run-context.d.ts +1 -0
  96. package/dist/server/agent-run-context.js +9 -0
  97. package/dist/server/core-routes-plugin.js +8 -1
  98. package/dist/server/request-context.d.ts +2 -0
  99. package/dist/server/transcribe-voice.d.ts +1 -1
  100. package/dist/shared/analytics-platform.d.ts +6 -0
  101. package/dist/shared/analytics-platform.js +14 -0
  102. package/dist/shared/mcp-embed-headers.d.ts +1 -1
  103. package/dist/shared/mcp-embed-headers.js +1 -1
  104. package/dist/styles/agent-native.css +83 -103
  105. package/dist/terminal/cli-registry.js +5 -0
  106. package/dist/tracking/registry.js +9 -1
  107. package/dist/triggers/actions/list-automations.d.ts +3 -0
  108. package/dist/triggers/actions/list-automations.js +3 -0
  109. package/dist/triggers/actions/manage-automation.d.ts +9 -0
  110. package/dist/triggers/actions/manage-automation.js +14 -2
  111. package/dist/triggers/actions.js +82 -7
  112. package/docs/content/template-content-developers.mdx +48 -0
  113. package/docs/content/toolkit-ui.mdx +57 -0
  114. package/package.json +2 -2
@@ -485,6 +485,7 @@ async function executeClaudeCliRun(options) {
485
485
  const streamToolOutputToStdout = options.streamToolOutputToStdout ??
486
486
  process.env.AGENT_NATIVE_CODE_AGENT_STRUCTURED_STDOUT !== "1";
487
487
  const assistantText = [];
488
+ const claudeToolNames = new Map();
488
489
  appendCodeAgentTranscriptEvent({
489
490
  runId: options.run.id,
490
491
  kind: "status",
@@ -511,7 +512,7 @@ async function executeClaudeCliRun(options) {
511
512
  effort: reasoningEffort,
512
513
  signal: options.signal,
513
514
  onEvent: (event) => {
514
- const text = readClaudeParticipantAssistantText(event);
515
+ const text = appendClaudeParticipantTranscriptEvents(options.run.id, event, claudeToolNames);
515
516
  if (!text)
516
517
  return;
517
518
  assistantText.push(text);
@@ -667,19 +668,246 @@ function normalizeClaudeCliModel(model) {
667
668
  function normalizeClaudeCliEffort(effort) {
668
669
  return effort && effort !== "auto" ? effort : undefined;
669
670
  }
670
- function readClaudeParticipantAssistantText(event) {
671
- if (event.type !== "assistant")
672
- return null;
671
+ function appendClaudeParticipantTranscriptEvents(runId, event, toolNames) {
672
+ const eventType = cliStringValue(event.type);
673
673
  const message = asRecordValue(event.message);
674
- const content = message?.content;
675
- if (!Array.isArray(content))
676
- return null;
677
- const text = content
678
- .filter((part) => isRecordValue(part))
679
- .map((part) => (typeof part.text === "string" ? part.text : ""))
680
- .filter(Boolean)
681
- .join("");
682
- return text.trim() || null;
674
+ const messageContent = Array.isArray(message?.content)
675
+ ? message.content.filter((part) => isRecordValue(part))
676
+ : [];
677
+ const content = messageContent.length > 0
678
+ ? messageContent
679
+ : eventType === "tool_use" || eventType === "tool_result"
680
+ ? [event]
681
+ : [];
682
+ let assistantText = "";
683
+ for (const part of content) {
684
+ const partType = cliStringValue(part.type);
685
+ if (eventType === "assistant" && partType === "text") {
686
+ const text = typeof part.text === "string" ? part.text : "";
687
+ if (!text.trim())
688
+ continue;
689
+ assistantText += text;
690
+ appendCodeAgentTranscriptEvent({
691
+ runId,
692
+ kind: "system",
693
+ message: text,
694
+ metadata: { role: "assistant", source: "claude-cli" },
695
+ });
696
+ continue;
697
+ }
698
+ if (eventType === "assistant" && partType === "thinking") {
699
+ const thinking = cliTranscriptValue(part.thinking ?? part.text);
700
+ if (!thinking)
701
+ continue;
702
+ appendCodeAgentTranscriptEvent({
703
+ runId,
704
+ kind: "status",
705
+ message: thinking,
706
+ metadata: { type: "thinking", source: "claude-cli" },
707
+ });
708
+ continue;
709
+ }
710
+ if (partType === "tool_use") {
711
+ const toolName = cliStringValue(part.name) ?? cliStringValue(part.tool_name) ?? "tool";
712
+ const toolCallId = cliStringValue(part.id);
713
+ if (toolCallId)
714
+ toolNames.set(toolCallId, toolName);
715
+ appendCodeAgentTranscriptEvent({
716
+ runId,
717
+ kind: "status",
718
+ message: `Running ${toolName}.`,
719
+ metadata: {
720
+ type: "tool_start",
721
+ tool: toolName,
722
+ input: part.input ?? {},
723
+ ...(toolCallId ? { toolCallId } : {}),
724
+ source: "claude-cli",
725
+ },
726
+ });
727
+ continue;
728
+ }
729
+ if (partType === "tool_result") {
730
+ const toolCallId = cliStringValue(part.tool_use_id);
731
+ const toolName = cliStringValue(part.tool_name) ??
732
+ (toolCallId ? toolNames.get(toolCallId) : undefined) ??
733
+ "tool";
734
+ const result = cliTranscriptValue(part.content ?? part.output ?? part.result ?? "");
735
+ appendCodeAgentTranscriptEvent({
736
+ runId,
737
+ kind: "status",
738
+ message: `Finished ${toolName}.`,
739
+ metadata: {
740
+ type: "tool_done",
741
+ tool: toolName,
742
+ result,
743
+ ...(part.is_error === true ? { isError: true } : {}),
744
+ ...(toolCallId ? { toolCallId } : {}),
745
+ source: "claude-cli",
746
+ },
747
+ });
748
+ if (toolCallId)
749
+ toolNames.delete(toolCallId);
750
+ }
751
+ }
752
+ return assistantText.trim() || null;
753
+ }
754
+ function appendCodexCliTranscriptEvent(runId, event) {
755
+ const eventType = cliStringValue(event.type);
756
+ const item = asRecordValue(event.item);
757
+ if (eventType?.startsWith("item.") && item) {
758
+ const itemType = cliStringValue(item.type);
759
+ if (itemType === "agent_message") {
760
+ const text = cliStringValue(item.text ?? item.message ?? item.content);
761
+ if (text) {
762
+ appendCodeAgentTranscriptEvent({
763
+ runId,
764
+ kind: "system",
765
+ message: text,
766
+ metadata: {
767
+ role: "assistant",
768
+ source: "codex-cli",
769
+ cliEventType: eventType,
770
+ itemType,
771
+ },
772
+ });
773
+ }
774
+ return;
775
+ }
776
+ if (itemType === "reasoning") {
777
+ const text = cliTranscriptValue(item.text ?? item.summary);
778
+ if (text) {
779
+ appendCodeAgentTranscriptEvent({
780
+ runId,
781
+ kind: "status",
782
+ message: text,
783
+ metadata: {
784
+ type: "thinking",
785
+ source: "codex-cli",
786
+ cliEventType: eventType,
787
+ itemType,
788
+ },
789
+ });
790
+ }
791
+ return;
792
+ }
793
+ const toolName = codexCliToolName(itemType, item);
794
+ if (!toolName)
795
+ return;
796
+ const toolCallId = cliStringValue(item.id);
797
+ const metadata = {
798
+ source: "codex-cli",
799
+ cliEventType: eventType,
800
+ itemType,
801
+ tool: toolName,
802
+ ...(toolCallId ? { toolCallId } : {}),
803
+ };
804
+ if (eventType === "item.started") {
805
+ appendCodeAgentTranscriptEvent({
806
+ runId,
807
+ kind: "status",
808
+ message: `Running ${toolName}.`,
809
+ metadata: {
810
+ ...metadata,
811
+ type: "tool_start",
812
+ input: codexCliToolInput(item),
813
+ },
814
+ });
815
+ }
816
+ else if (eventType === "item.completed") {
817
+ appendCodeAgentTranscriptEvent({
818
+ runId,
819
+ kind: "status",
820
+ message: `Finished ${toolName}.`,
821
+ metadata: {
822
+ ...metadata,
823
+ type: "tool_done",
824
+ result: cliTranscriptValue(codexCliToolResult(item)),
825
+ },
826
+ });
827
+ }
828
+ else {
829
+ appendCodeAgentTranscriptEvent({
830
+ runId,
831
+ kind: "status",
832
+ message: `Working with ${toolName}.`,
833
+ metadata: { ...metadata, type: "activity" },
834
+ });
835
+ }
836
+ return;
837
+ }
838
+ if (eventType === "error" || eventType === "turn.failed") {
839
+ const message = cliStringValue(event.message ?? event.error) ?? eventType;
840
+ appendCodeAgentTranscriptEvent({
841
+ runId,
842
+ kind: "status",
843
+ message,
844
+ metadata: { type: "error", source: "codex-cli", cliEventType: eventType },
845
+ });
846
+ }
847
+ }
848
+ function codexCliToolName(itemType, item) {
849
+ switch (itemType) {
850
+ case "command_execution":
851
+ return "bash";
852
+ case "file_change":
853
+ return "file-change";
854
+ case "mcp_tool_call":
855
+ return (cliStringValue(item.name) ?? cliStringValue(item.tool) ?? "mcp-tool");
856
+ case "web_search":
857
+ return "web-search";
858
+ case "function_call":
859
+ return cliStringValue(item.name) ?? "function";
860
+ default:
861
+ return itemType?.includes("tool")
862
+ ? (cliStringValue(item.name) ?? itemType)
863
+ : null;
864
+ }
865
+ }
866
+ function codexCliToolInput(item) {
867
+ if (typeof item.command === "string")
868
+ return { command: item.command };
869
+ return item.arguments ?? item.input ?? item.params ?? item.changes ?? {};
870
+ }
871
+ function codexCliToolResult(item) {
872
+ return (item.aggregated_output ??
873
+ item.output ??
874
+ item.result ??
875
+ item.error ??
876
+ item.content ??
877
+ item.status ??
878
+ "");
879
+ }
880
+ function consumeCodexJsonLine(line, onEvent) {
881
+ const trimmed = line.trim();
882
+ if (!trimmed.startsWith("{"))
883
+ return;
884
+ try {
885
+ const parsed = JSON.parse(trimmed);
886
+ if (isRecordValue(parsed))
887
+ onEvent?.(parsed);
888
+ }
889
+ catch {
890
+ // coercion-ok: older CLI output is intentionally ignored when it is not JSON.
891
+ // Older Codex versions and test doubles can still emit human-readable
892
+ // stdout. Keep that output available to terminal callers without making
893
+ // the structured transcript parser fail the run.
894
+ }
895
+ }
896
+ function cliStringValue(value) {
897
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
898
+ }
899
+ function cliTranscriptValue(value) {
900
+ if (typeof value === "string") {
901
+ return truncateBashOutput(truncateCodingOutput(value, MAX_TOOL_OUTPUT_CHARS));
902
+ }
903
+ if (value == null)
904
+ return "";
905
+ try {
906
+ return truncateBashOutput(truncateCodingOutput(JSON.stringify(value) ?? "", MAX_TOOL_OUTPUT_CHARS));
907
+ }
908
+ catch {
909
+ return truncateCodingOutput(String(value), MAX_TOOL_OUTPUT_CHARS);
910
+ }
683
911
  }
684
912
  function readClaudeParticipantResultText(events) {
685
913
  for (let index = events.length - 1; index >= 0; index -= 1) {
@@ -1006,6 +1234,7 @@ async function executeCodexCliRun(options) {
1006
1234
  "exec",
1007
1235
  "--color",
1008
1236
  "never",
1237
+ "--json",
1009
1238
  "--skip-git-repo-check",
1010
1239
  "--ignore-user-config",
1011
1240
  "--output-last-message",
@@ -1034,6 +1263,9 @@ async function executeCodexCliRun(options) {
1034
1263
  prompt: buildCodexCliPrompt(options.run, options.prompt),
1035
1264
  stdout: options.stdout,
1036
1265
  streamToolOutputToStdout,
1266
+ onEvent: (event) => {
1267
+ appendCodexCliTranscriptEvent(options.run.id, event);
1268
+ },
1037
1269
  signal: options.signal,
1038
1270
  });
1039
1271
  if (result.exitCode !== 0) {
@@ -1163,6 +1395,7 @@ function runCodexCliProcess(options) {
1163
1395
  return new Promise((resolve) => {
1164
1396
  let stdout = "";
1165
1397
  let stderr = "";
1398
+ let pendingJson = "";
1166
1399
  let settled = false;
1167
1400
  const child = spawn("codex", options.args, {
1168
1401
  cwd: options.cwd,
@@ -1188,6 +1421,13 @@ function runCodexCliProcess(options) {
1188
1421
  child.stdout?.on("data", (chunk) => {
1189
1422
  const text = chunk.toString();
1190
1423
  stdout += text;
1424
+ pendingJson += text;
1425
+ let newline = pendingJson.indexOf("\n");
1426
+ while (newline !== -1) {
1427
+ consumeCodexJsonLine(pendingJson.slice(0, newline), options.onEvent);
1428
+ pendingJson = pendingJson.slice(newline + 1);
1429
+ newline = pendingJson.indexOf("\n");
1430
+ }
1191
1431
  if (options.streamToolOutputToStdout ?? true) {
1192
1432
  options.stdout?.write(text);
1193
1433
  }
@@ -1207,6 +1447,8 @@ function runCodexCliProcess(options) {
1207
1447
  });
1208
1448
  });
1209
1449
  child.on("exit", (exitCode, exitSignal) => {
1450
+ if (pendingJson.trim())
1451
+ consumeCodexJsonLine(pendingJson, options.onEvent);
1210
1452
  finish({ exitCode, exitSignal });
1211
1453
  });
1212
1454
  child.stdin?.end(options.prompt);
@@ -65,6 +65,7 @@ export interface CodeAgentTranscriptEvent {
65
65
  signal?: CodeAgentTranscriptEventSignal;
66
66
  }
67
67
  export interface CreateCodeAgentRunInput {
68
+ id?: string;
68
69
  goalId: string;
69
70
  title: string;
70
71
  subtitle?: string;
@@ -65,7 +65,8 @@ export function isCodeAgentCommandAllowed(command) {
65
65
  }
66
66
  export function createCodeAgentRunRecord(input) {
67
67
  const now = new Date().toISOString();
68
- const id = `${input.goalId}-${timestampSlug(now)}-${crypto.randomUUID().slice(0, 8)}`;
68
+ const id = input.id ??
69
+ `${input.goalId}-${timestampSlug(now)}-${crypto.randomUUID().slice(0, 8)}`;
69
70
  const record = {
70
71
  schemaVersion: 1,
71
72
  id,
@@ -0,0 +1,49 @@
1
+ export interface PortalHandoff {
2
+ schemaVersion: 1;
3
+ handoffId: string;
4
+ branch: string;
5
+ remoteRef: string;
6
+ commit: string;
7
+ sourceBranch?: string;
8
+ sourceDirty: boolean;
9
+ createdCommit: boolean;
10
+ repositoryName: string;
11
+ remoteName: string;
12
+ envPolicy: "load-local";
13
+ }
14
+ export interface PortalEnvironment {
15
+ values: Record<string, string>;
16
+ files: string[];
17
+ root: string;
18
+ }
19
+ export interface PortalWorkspace {
20
+ handoff: PortalHandoff;
21
+ repositoryPath: string;
22
+ workspacePath: string;
23
+ environmentRoot: string;
24
+ environmentFiles: string[];
25
+ reused: boolean;
26
+ }
27
+ export interface PortalGitResult {
28
+ status: number | null;
29
+ stdout?: string;
30
+ stderr?: string;
31
+ error?: Error;
32
+ }
33
+ export type RunPortalGit = (args: string[], cwd: string, env?: NodeJS.ProcessEnv) => PortalGitResult | Promise<PortalGitResult>;
34
+ export declare function createPortalHandoff(input: {
35
+ sourcePath: string;
36
+ remoteName?: string;
37
+ handoffId?: string;
38
+ now?: Date;
39
+ runGit?: RunPortalGit;
40
+ }): Promise<PortalHandoff>;
41
+ export declare function preparePortalWorkspace(input: {
42
+ handoff: unknown;
43
+ workspacePath?: string;
44
+ worktreeRoot?: string;
45
+ runGit?: RunPortalGit;
46
+ }): Promise<PortalWorkspace>;
47
+ export declare function parsePortalHandoff(value: unknown): PortalHandoff;
48
+ export declare function listPortalEnvironmentFiles(root: string, mode?: string): string[];
49
+ export declare function loadPortalEnvironment(root: string, mode?: string): PortalEnvironment;