@stigmer/react 0.0.53 → 0.0.55

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 (118) hide show
  1. package/execution/ArtifactCard.d.ts +11 -1
  2. package/execution/ArtifactCard.d.ts.map +1 -1
  3. package/execution/ArtifactCard.js +22 -3
  4. package/execution/ArtifactCard.js.map +1 -1
  5. package/execution/ArtifactPreviewModal.d.ts.map +1 -1
  6. package/execution/ArtifactPreviewModal.js +1 -1
  7. package/execution/ArtifactPreviewModal.js.map +1 -1
  8. package/execution/ArtifactsWidget.d.ts +26 -19
  9. package/execution/ArtifactsWidget.d.ts.map +1 -1
  10. package/execution/ArtifactsWidget.js +32 -26
  11. package/execution/ArtifactsWidget.js.map +1 -1
  12. package/execution/MessageThread.d.ts +10 -1
  13. package/execution/MessageThread.d.ts.map +1 -1
  14. package/execution/MessageThread.js +21 -17
  15. package/execution/MessageThread.js.map +1 -1
  16. package/execution/SandboxContext.d.ts +32 -0
  17. package/execution/SandboxContext.d.ts.map +1 -0
  18. package/execution/SandboxContext.js +26 -0
  19. package/execution/SandboxContext.js.map +1 -0
  20. package/execution/SetupProgress.d.ts +23 -13
  21. package/execution/SetupProgress.d.ts.map +1 -1
  22. package/execution/SetupProgress.js +18 -12
  23. package/execution/SetupProgress.js.map +1 -1
  24. package/execution/ToolArgsView.d.ts.map +1 -1
  25. package/execution/ToolArgsView.js +3 -1
  26. package/execution/ToolArgsView.js.map +1 -1
  27. package/execution/ToolCallDetail.d.ts.map +1 -1
  28. package/execution/ToolCallDetail.js +3 -1
  29. package/execution/ToolCallDetail.js.map +1 -1
  30. package/execution/ToolCallItem.d.ts.map +1 -1
  31. package/execution/ToolCallItem.js +7 -1
  32. package/execution/ToolCallItem.js.map +1 -1
  33. package/execution/WriteBackCard.d.ts +34 -0
  34. package/execution/WriteBackCard.d.ts.map +1 -0
  35. package/execution/WriteBackCard.js +75 -0
  36. package/execution/WriteBackCard.js.map +1 -0
  37. package/execution/WriteBacksWidget.d.ts +49 -0
  38. package/execution/WriteBacksWidget.d.ts.map +1 -0
  39. package/execution/WriteBacksWidget.js +44 -0
  40. package/execution/WriteBacksWidget.js.map +1 -0
  41. package/execution/__tests__/file-path-resolver.test.d.ts +2 -0
  42. package/execution/__tests__/file-path-resolver.test.d.ts.map +1 -0
  43. package/execution/__tests__/file-path-resolver.test.js +180 -0
  44. package/execution/__tests__/file-path-resolver.test.js.map +1 -0
  45. package/execution/file-path-resolver.d.ts +3 -3
  46. package/execution/file-path-resolver.d.ts.map +1 -1
  47. package/execution/file-path-resolver.js +23 -12
  48. package/execution/file-path-resolver.js.map +1 -1
  49. package/execution/index.d.ts +9 -0
  50. package/execution/index.d.ts.map +1 -1
  51. package/execution/index.js +5 -0
  52. package/execution/index.js.map +1 -1
  53. package/execution/sandbox-path-normalizer.d.ts +46 -0
  54. package/execution/sandbox-path-normalizer.d.ts.map +1 -0
  55. package/execution/sandbox-path-normalizer.js +73 -0
  56. package/execution/sandbox-path-normalizer.js.map +1 -0
  57. package/execution/useArtifactContent.d.ts +5 -1
  58. package/execution/useArtifactContent.d.ts.map +1 -1
  59. package/execution/useArtifactContent.js +6 -2
  60. package/execution/useArtifactContent.js.map +1 -1
  61. package/execution/useWorkspaceWriteBacks.d.ts +40 -0
  62. package/execution/useWorkspaceWriteBacks.d.ts.map +1 -0
  63. package/execution/useWorkspaceWriteBacks.js +41 -0
  64. package/execution/useWorkspaceWriteBacks.js.map +1 -0
  65. package/github/GitHubRepoPicker.d.ts +5 -2
  66. package/github/GitHubRepoPicker.d.ts.map +1 -1
  67. package/github/GitHubRepoPicker.js +133 -36
  68. package/github/GitHubRepoPicker.js.map +1 -1
  69. package/github/index.d.ts +1 -0
  70. package/github/index.d.ts.map +1 -1
  71. package/github/index.js +1 -0
  72. package/github/index.js.map +1 -1
  73. package/github/useGitHubSearch.d.ts +20 -0
  74. package/github/useGitHubSearch.d.ts.map +1 -0
  75. package/github/useGitHubSearch.js +127 -0
  76. package/github/useGitHubSearch.js.map +1 -0
  77. package/index.d.ts +6 -6
  78. package/index.d.ts.map +1 -1
  79. package/index.js +3 -3
  80. package/index.js.map +1 -1
  81. package/package.json +4 -4
  82. package/session/index.d.ts +4 -0
  83. package/session/index.d.ts.map +1 -1
  84. package/session/index.js +2 -0
  85. package/session/index.js.map +1 -1
  86. package/session/useSessionArtifacts.d.ts +73 -0
  87. package/session/useSessionArtifacts.d.ts.map +1 -0
  88. package/session/useSessionArtifacts.js +95 -0
  89. package/session/useSessionArtifacts.js.map +1 -0
  90. package/session/useSessionWriteBacks.d.ts +56 -0
  91. package/session/useSessionWriteBacks.d.ts.map +1 -0
  92. package/session/useSessionWriteBacks.js +56 -0
  93. package/session/useSessionWriteBacks.js.map +1 -0
  94. package/src/execution/ArtifactCard.tsx +40 -0
  95. package/src/execution/ArtifactPreviewModal.tsx +2 -0
  96. package/src/execution/ArtifactsWidget.tsx +67 -43
  97. package/src/execution/MessageThread.tsx +23 -1
  98. package/src/execution/SandboxContext.ts +47 -0
  99. package/src/execution/SetupProgress.tsx +33 -14
  100. package/src/execution/ToolArgsView.tsx +3 -1
  101. package/src/execution/ToolCallDetail.tsx +3 -1
  102. package/src/execution/ToolCallItem.tsx +7 -1
  103. package/src/execution/WriteBackCard.tsx +210 -0
  104. package/src/execution/WriteBacksWidget.tsx +82 -0
  105. package/src/execution/__tests__/file-path-resolver.test.ts +295 -0
  106. package/src/execution/file-path-resolver.ts +24 -12
  107. package/src/execution/index.ts +13 -0
  108. package/src/execution/sandbox-path-normalizer.ts +80 -0
  109. package/src/execution/useArtifactContent.ts +6 -1
  110. package/src/execution/useWorkspaceWriteBacks.ts +56 -0
  111. package/src/github/GitHubRepoPicker.tsx +413 -108
  112. package/src/github/index.ts +5 -0
  113. package/src/github/useGitHubSearch.ts +162 -0
  114. package/src/index.ts +14 -0
  115. package/src/session/index.ts +12 -0
  116. package/src/session/useSessionArtifacts.ts +143 -0
  117. package/src/session/useSessionWriteBacks.ts +94 -0
  118. package/styles.css +1 -1
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Display-time normalization for sandbox workspace paths.
3
+ *
4
+ * Mirrors the Python `humanize_sandbox_paths` in
5
+ * `graphton.core.backends.platform_mount` — same semantics, same
6
+ * replacement order. The SDK version acts as a safety net for
7
+ * historical data (persisted before backend humanization was added)
8
+ * and streaming edge cases.
9
+ *
10
+ * @module
11
+ */
12
+
13
+ /**
14
+ * Replace absolute sandbox workspace paths with workspace-relative
15
+ * display paths.
16
+ *
17
+ * Performs three ordered replacements:
18
+ *
19
+ * 1. `workspaceRoot + "/"` → empty string (makes paths workspace-relative)
20
+ * 2. `workspaceRoot` (exact) → `"."` (the workspace root itself)
21
+ * 3. Parent of `workspaceRoot` (sandbox home) → `"~"` (Unix convention)
22
+ *
23
+ * Returns `text` unchanged when `workspaceRoot` is empty.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * normalizeSandboxPaths(
28
+ * "ls /home/daytona/workspace/plantonhq/",
29
+ * "/home/daytona/workspace",
30
+ * );
31
+ * // => "ls plantonhq/"
32
+ *
33
+ * normalizeSandboxPaths(
34
+ * "cd /home/daytona/workspace && ls",
35
+ * "/home/daytona/workspace",
36
+ * );
37
+ * // => "cd . && ls"
38
+ *
39
+ * normalizeSandboxPaths(
40
+ * "cat /home/daytona/.bashrc",
41
+ * "/home/daytona/workspace",
42
+ * );
43
+ * // => "cat ~/.bashrc"
44
+ * ```
45
+ */
46
+ export function normalizeSandboxPaths(
47
+ text: string,
48
+ workspaceRoot: string,
49
+ ): string {
50
+ if (!text || !workspaceRoot) return text;
51
+
52
+ const wsRoot = workspaceRoot.replace(/\/+$/, "");
53
+
54
+ // 1) Strip workspace root prefix (with trailing slash) → workspace-relative
55
+ text = replaceAll(text, wsRoot + "/", "");
56
+
57
+ // 2) Replace bare workspace root → "."
58
+ text = replaceAll(text, wsRoot, ".");
59
+
60
+ // 3) Replace sandbox home prefix → "~"
61
+ const lastSlash = wsRoot.lastIndexOf("/");
62
+ if (lastSlash > 0) {
63
+ const sandboxHome = wsRoot.slice(0, lastSlash);
64
+ text = replaceAll(text, sandboxHome + "/", "~/");
65
+ text = replaceAll(text, sandboxHome, "~");
66
+ }
67
+
68
+ return text;
69
+ }
70
+
71
+ function replaceAll(text: string, search: string, replacement: string): string {
72
+ if (!search) return text;
73
+ let result = text;
74
+ let idx = result.indexOf(search);
75
+ while (idx !== -1) {
76
+ result = result.slice(0, idx) + replacement + result.slice(idx + search.length);
77
+ idx = result.indexOf(search, idx + replacement.length);
78
+ }
79
+ return result;
80
+ }
@@ -80,6 +80,10 @@ export interface UseArtifactContentReturn {
80
80
  * @param storageKey - Storage key from `ExecutionArtifact.storageKey`, or `null` to skip.
81
81
  * @param entryPath - For directory artifacts: relative path of a file within
82
82
  * the archive to extract. `null` returns the full artifact (existing behavior).
83
+ * @param contentHash - SHA-256 hex digest from `ExecutionArtifact.contentHash`.
84
+ * When the same file is overwritten during execution, the `storageKey` stays
85
+ * stable but `contentHash` changes, triggering a re-fetch so the UI never
86
+ * shows stale content. Pass `undefined` or omit for backwards compatibility.
83
87
  *
84
88
  * @see useExecutionArtifacts — extracts artifact metadata from an execution
85
89
  * @see isTextArtifact — heuristic for whether content is fetchable as text
@@ -88,6 +92,7 @@ export function useArtifactContent(
88
92
  executionId: string | null,
89
93
  storageKey: string | null,
90
94
  entryPath?: string | null,
95
+ contentHash?: string,
91
96
  ): UseArtifactContentReturn {
92
97
  const stigmer = useStigmer();
93
98
 
@@ -150,7 +155,7 @@ export function useArtifactContent(
150
155
  return () => {
151
156
  cancelled.current = true;
152
157
  };
153
- }, [executionId, storageKey, entryPath, stigmer, fetchKey]);
158
+ }, [executionId, storageKey, entryPath, contentHash, stigmer, fetchKey]);
154
159
 
155
160
  return { content, contentType, isTruncated, isLoading, error, refetch };
156
161
  }
@@ -0,0 +1,56 @@
1
+ "use client";
2
+
3
+ import { useMemo } from "react";
4
+ import type { AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
5
+ import type { WorkspaceWriteBack } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/writeback_pb";
6
+
7
+ export interface UseWorkspaceWriteBacksReturn {
8
+ /** Write-back outcomes for git-backed workspace entries, ordered by workspace entry name. */
9
+ readonly writeBacks: readonly WorkspaceWriteBack[];
10
+ /** `true` when the execution has at least one write-back entry. */
11
+ readonly hasWriteBacks: boolean;
12
+ /** Total number of write-back entries. */
13
+ readonly writeBackCount: number;
14
+ }
15
+
16
+ /**
17
+ * Pure derivation hook that extracts workspace write-back data from an
18
+ * {@link AgentExecution} snapshot.
19
+ *
20
+ * Follows the same `useMemo`-based derivation pattern as
21
+ * {@link useExecutionArtifacts}: no side effects, no data fetching.
22
+ * The execution object (typically from {@link useExecutionStream}) is
23
+ * the single input.
24
+ *
25
+ * Returns an empty array when the execution is `null` or has no
26
+ * write-backs, eliminating null-checking at every consumer call site.
27
+ *
28
+ * Each `WorkspaceWriteBack` entry corresponds to a git-backed workspace
29
+ * entry where the platform detected file changes and ran the automatic
30
+ * branch/commit/push/PR workflow.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * const { execution } = useExecutionStream(executionId);
35
+ * const { writeBacks, hasWriteBacks } = useWorkspaceWriteBacks(execution);
36
+ *
37
+ * if (hasWriteBacks) {
38
+ * writeBacks.forEach((wb) => console.log(wb.workspaceEntryName, wb.pullRequestUrl));
39
+ * }
40
+ * ```
41
+ *
42
+ * @see useExecutionArtifacts — similar derivation hook for artifacts
43
+ */
44
+ export function useWorkspaceWriteBacks(
45
+ execution: AgentExecution | null,
46
+ ): UseWorkspaceWriteBacksReturn {
47
+ return useMemo(() => {
48
+ const writeBacks = execution?.status?.workspaceWriteBacks ?? [];
49
+
50
+ return {
51
+ writeBacks,
52
+ hasWriteBacks: writeBacks.length > 0,
53
+ writeBackCount: writeBacks.length,
54
+ };
55
+ }, [execution]);
56
+ }