@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.
- package/execution/ArtifactCard.d.ts +11 -1
- package/execution/ArtifactCard.d.ts.map +1 -1
- package/execution/ArtifactCard.js +22 -3
- package/execution/ArtifactCard.js.map +1 -1
- package/execution/ArtifactPreviewModal.d.ts.map +1 -1
- package/execution/ArtifactPreviewModal.js +1 -1
- package/execution/ArtifactPreviewModal.js.map +1 -1
- package/execution/ArtifactsWidget.d.ts +26 -19
- package/execution/ArtifactsWidget.d.ts.map +1 -1
- package/execution/ArtifactsWidget.js +32 -26
- package/execution/ArtifactsWidget.js.map +1 -1
- package/execution/MessageThread.d.ts +10 -1
- package/execution/MessageThread.d.ts.map +1 -1
- package/execution/MessageThread.js +21 -17
- package/execution/MessageThread.js.map +1 -1
- package/execution/SandboxContext.d.ts +32 -0
- package/execution/SandboxContext.d.ts.map +1 -0
- package/execution/SandboxContext.js +26 -0
- package/execution/SandboxContext.js.map +1 -0
- package/execution/SetupProgress.d.ts +23 -13
- package/execution/SetupProgress.d.ts.map +1 -1
- package/execution/SetupProgress.js +18 -12
- package/execution/SetupProgress.js.map +1 -1
- package/execution/ToolArgsView.d.ts.map +1 -1
- package/execution/ToolArgsView.js +3 -1
- package/execution/ToolArgsView.js.map +1 -1
- package/execution/ToolCallDetail.d.ts.map +1 -1
- package/execution/ToolCallDetail.js +3 -1
- package/execution/ToolCallDetail.js.map +1 -1
- package/execution/ToolCallItem.d.ts.map +1 -1
- package/execution/ToolCallItem.js +7 -1
- package/execution/ToolCallItem.js.map +1 -1
- package/execution/WriteBackCard.d.ts +34 -0
- package/execution/WriteBackCard.d.ts.map +1 -0
- package/execution/WriteBackCard.js +75 -0
- package/execution/WriteBackCard.js.map +1 -0
- package/execution/WriteBacksWidget.d.ts +49 -0
- package/execution/WriteBacksWidget.d.ts.map +1 -0
- package/execution/WriteBacksWidget.js +44 -0
- package/execution/WriteBacksWidget.js.map +1 -0
- package/execution/__tests__/file-path-resolver.test.d.ts +2 -0
- package/execution/__tests__/file-path-resolver.test.d.ts.map +1 -0
- package/execution/__tests__/file-path-resolver.test.js +180 -0
- package/execution/__tests__/file-path-resolver.test.js.map +1 -0
- package/execution/file-path-resolver.d.ts +3 -3
- package/execution/file-path-resolver.d.ts.map +1 -1
- package/execution/file-path-resolver.js +23 -12
- package/execution/file-path-resolver.js.map +1 -1
- package/execution/index.d.ts +9 -0
- package/execution/index.d.ts.map +1 -1
- package/execution/index.js +5 -0
- package/execution/index.js.map +1 -1
- package/execution/sandbox-path-normalizer.d.ts +46 -0
- package/execution/sandbox-path-normalizer.d.ts.map +1 -0
- package/execution/sandbox-path-normalizer.js +73 -0
- package/execution/sandbox-path-normalizer.js.map +1 -0
- package/execution/useArtifactContent.d.ts +5 -1
- package/execution/useArtifactContent.d.ts.map +1 -1
- package/execution/useArtifactContent.js +6 -2
- package/execution/useArtifactContent.js.map +1 -1
- package/execution/useWorkspaceWriteBacks.d.ts +40 -0
- package/execution/useWorkspaceWriteBacks.d.ts.map +1 -0
- package/execution/useWorkspaceWriteBacks.js +41 -0
- package/execution/useWorkspaceWriteBacks.js.map +1 -0
- package/github/GitHubRepoPicker.d.ts +5 -2
- package/github/GitHubRepoPicker.d.ts.map +1 -1
- package/github/GitHubRepoPicker.js +133 -36
- package/github/GitHubRepoPicker.js.map +1 -1
- package/github/index.d.ts +1 -0
- package/github/index.d.ts.map +1 -1
- package/github/index.js +1 -0
- package/github/index.js.map +1 -1
- package/github/useGitHubSearch.d.ts +20 -0
- package/github/useGitHubSearch.d.ts.map +1 -0
- package/github/useGitHubSearch.js +127 -0
- package/github/useGitHubSearch.js.map +1 -0
- package/index.d.ts +6 -6
- package/index.d.ts.map +1 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/session/index.d.ts +4 -0
- package/session/index.d.ts.map +1 -1
- package/session/index.js +2 -0
- package/session/index.js.map +1 -1
- package/session/useSessionArtifacts.d.ts +73 -0
- package/session/useSessionArtifacts.d.ts.map +1 -0
- package/session/useSessionArtifacts.js +95 -0
- package/session/useSessionArtifacts.js.map +1 -0
- package/session/useSessionWriteBacks.d.ts +56 -0
- package/session/useSessionWriteBacks.d.ts.map +1 -0
- package/session/useSessionWriteBacks.js +56 -0
- package/session/useSessionWriteBacks.js.map +1 -0
- package/src/execution/ArtifactCard.tsx +40 -0
- package/src/execution/ArtifactPreviewModal.tsx +2 -0
- package/src/execution/ArtifactsWidget.tsx +67 -43
- package/src/execution/MessageThread.tsx +23 -1
- package/src/execution/SandboxContext.ts +47 -0
- package/src/execution/SetupProgress.tsx +33 -14
- package/src/execution/ToolArgsView.tsx +3 -1
- package/src/execution/ToolCallDetail.tsx +3 -1
- package/src/execution/ToolCallItem.tsx +7 -1
- package/src/execution/WriteBackCard.tsx +210 -0
- package/src/execution/WriteBacksWidget.tsx +82 -0
- package/src/execution/__tests__/file-path-resolver.test.ts +295 -0
- package/src/execution/file-path-resolver.ts +24 -12
- package/src/execution/index.ts +13 -0
- package/src/execution/sandbox-path-normalizer.ts +80 -0
- package/src/execution/useArtifactContent.ts +6 -1
- package/src/execution/useWorkspaceWriteBacks.ts +56 -0
- package/src/github/GitHubRepoPicker.tsx +413 -108
- package/src/github/index.ts +5 -0
- package/src/github/useGitHubSearch.ts +162 -0
- package/src/index.ts +14 -0
- package/src/session/index.ts +12 -0
- package/src/session/useSessionArtifacts.ts +143 -0
- package/src/session/useSessionWriteBacks.ts +94 -0
- 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
|
+
}
|