@field-studio/sdk 0.0.0-stage → 0.1.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +131 -2
  3. package/dist/index.d.ts +97 -0
  4. package/dist/index.js +129 -0
  5. package/dist/node/identity.d.ts +68 -0
  6. package/dist/node/identity.js +1 -0
  7. package/dist/node/index.d.ts +41 -0
  8. package/dist/node/index.js +165 -0
  9. package/dist/react/agent/AgentEditor.d.ts +16 -0
  10. package/dist/react/agent/AgentEditor.js +51 -0
  11. package/dist/react/agent/MCPManager.d.ts +12 -0
  12. package/dist/react/agent/MCPManager.js +72 -0
  13. package/dist/react/agent/SkillImport.d.ts +8 -0
  14. package/dist/react/agent/SkillImport.js +31 -0
  15. package/dist/react/agent/SkillViewer.d.ts +7 -0
  16. package/dist/react/agent/SkillViewer.js +61 -0
  17. package/dist/react/agent/catalog.css +205 -0
  18. package/dist/react/agent/index.d.ts +7 -0
  19. package/dist/react/agent/index.js +5 -0
  20. package/dist/react/agent/skillTitle.d.ts +3 -0
  21. package/dist/react/agent/skillTitle.js +4 -0
  22. package/dist/react/agent/types.d.ts +46 -0
  23. package/dist/react/agent/types.js +1 -0
  24. package/dist/react/assistant/AssistantPanel.d.ts +15 -0
  25. package/dist/react/assistant/AssistantPanel.js +144 -0
  26. package/dist/react/assistant/AssistantProvider.d.ts +119 -0
  27. package/dist/react/assistant/AssistantProvider.js +427 -0
  28. package/dist/react/assistant/QuestionPanel.d.ts +8 -0
  29. package/dist/react/assistant/QuestionPanel.js +32 -0
  30. package/dist/react/assistant/TaskComposer.d.ts +25 -0
  31. package/dist/react/assistant/TaskComposer.js +354 -0
  32. package/dist/react/assistant/TaskFiles.d.ts +24 -0
  33. package/dist/react/assistant/TaskFiles.js +107 -0
  34. package/dist/react/assistant/assistant.css +428 -0
  35. package/dist/react/assistant/composer.css +116 -0
  36. package/dist/react/assistant/files.css +19 -0
  37. package/dist/react/assistant/index.d.ts +10 -0
  38. package/dist/react/assistant/index.js +6 -0
  39. package/dist/react/assistant/layout.d.ts +7 -0
  40. package/dist/react/assistant/layout.js +19 -0
  41. package/dist/react/assistant/messages.d.ts +355 -0
  42. package/dist/react/assistant/messages.js +239 -0
  43. package/dist/react/assistant/questions.css +6 -0
  44. package/dist/react/assistant/types.d.ts +85 -0
  45. package/dist/react/assistant/types.js +1 -0
  46. package/dist/react/auth/AuthShell.d.ts +35 -0
  47. package/dist/react/auth/AuthShell.js +197 -0
  48. package/dist/react/auth/RoleManager.d.ts +23 -0
  49. package/dist/react/auth/RoleManager.js +95 -0
  50. package/dist/react/auth/auth.css +70 -0
  51. package/dist/react/auth/index.d.ts +2 -0
  52. package/dist/react/auth/index.js +1 -0
  53. package/dist/react/index.d.ts +57 -0
  54. package/dist/react/index.js +177 -0
  55. package/dist/react/ui/Controls.d.ts +78 -0
  56. package/dist/react/ui/Controls.js +234 -0
  57. package/dist/react/ui/base.css +261 -0
  58. package/dist/react/ui/controls.css +35 -0
  59. package/dist/react/ui/index.d.ts +2 -0
  60. package/dist/react/ui/index.js +2 -0
  61. package/dist/workspace.d.ts +107 -0
  62. package/dist/workspace.js +139 -0
  63. package/package.json +86 -3
@@ -0,0 +1,261 @@
1
+ :root {
2
+ font-family:
3
+ "DM Sans",
4
+ -apple-system,
5
+ BlinkMacSystemFont,
6
+ "PingFang SC",
7
+ "Microsoft YaHei",
8
+ sans-serif;
9
+ color: #25344b;
10
+ background: #f4f6fa;
11
+ font-synthesis: none;
12
+ font-size: 13px;
13
+ line-height: 1.6;
14
+ font-weight: 400;
15
+ }
16
+ * {
17
+ box-sizing: border-box;
18
+ }
19
+ body {
20
+ margin: 0;
21
+ }
22
+ button,
23
+ input,
24
+ textarea,
25
+ select {
26
+ font: inherit;
27
+ }
28
+ button {
29
+ cursor: pointer;
30
+ color: inherit;
31
+ }
32
+ button:disabled {
33
+ cursor: not-allowed;
34
+ opacity: 0.5;
35
+ }
36
+ button,
37
+ a,
38
+ input,
39
+ textarea,
40
+ select {
41
+ outline-offset: 3px;
42
+ }
43
+ button:focus-visible,
44
+ a:focus-visible {
45
+ outline: 3px solid #94b7fa;
46
+ }
47
+ button {
48
+ border: 0;
49
+ background: none;
50
+ }
51
+ button svg {
52
+ flex-shrink: 0;
53
+ }
54
+ input,
55
+ textarea,
56
+ select {
57
+ color: inherit;
58
+ border: 1px solid #e2e7ef;
59
+ border-radius: 7px;
60
+ background: #fff;
61
+ padding: 9px 11px;
62
+ }
63
+ input:focus,
64
+ textarea:focus,
65
+ select:focus {
66
+ outline: 2px solid #b7d0ff;
67
+ border-color: #6b9bea;
68
+ }
69
+ textarea {
70
+ resize: vertical;
71
+ }
72
+ h1,
73
+ h2,
74
+ h3,
75
+ h4,
76
+ p {
77
+ margin: 0;
78
+ }
79
+ h1 {
80
+ font-size: 24px;
81
+ font-weight: 650;
82
+ letter-spacing: -0.7px;
83
+ }
84
+ h2 {
85
+ font-size: 16px;
86
+ font-weight: 650;
87
+ }
88
+ h3 {
89
+ font-size: 14px;
90
+ }
91
+ h4 {
92
+ font-size: 13px;
93
+ }
94
+ small,
95
+ .muted {
96
+ color: #586b83;
97
+ }
98
+ .tag {
99
+ display: inline-flex;
100
+ align-items: center;
101
+ gap: 5px;
102
+ font-size: 11px;
103
+ border-radius: 4px;
104
+ padding: 2px 7px;
105
+ white-space: nowrap;
106
+ background: #f0f3f8;
107
+ color: #586b83;
108
+ }
109
+ .tag.blue {
110
+ color: #4874cb;
111
+ background: #edf3ff;
112
+ }
113
+ .tag.green {
114
+ color: #586b83;
115
+ background: #eaf7f0;
116
+ }
117
+ .tag.orange {
118
+ color: #c88430;
119
+ background: #fff4e4;
120
+ }
121
+ .tag.red {
122
+ color: #d36363;
123
+ background: #fdf0ef;
124
+ }
125
+ .icon-button {
126
+ display: inline-flex;
127
+ align-items: center;
128
+ justify-content: center;
129
+ padding: 6px;
130
+ border-radius: 6px;
131
+ position: relative;
132
+ }
133
+ .icon-button:hover {
134
+ background: #edf2f9;
135
+ }
136
+ .button {
137
+ display: inline-flex;
138
+ align-items: center;
139
+ justify-content: center;
140
+ gap: 6px;
141
+ padding: 8px 13px;
142
+ border: 1px solid #dfe6ef;
143
+ border-radius: 7px;
144
+ background: white;
145
+ line-height: 1.5;
146
+ white-space: nowrap;
147
+ font-size: 12px;
148
+ }
149
+ .button:hover {
150
+ background: #f4f7fc;
151
+ }
152
+ .button.primary {
153
+ background: #3169e5;
154
+ border-color: #3169e5;
155
+ color: white;
156
+ box-shadow: 0 3px 7px #3169e513;
157
+ }
158
+ .button.primary:hover {
159
+ background: #2458cc;
160
+ }
161
+ .button.small {
162
+ padding: 5px 9px;
163
+ font-size: 11px;
164
+ }
165
+ .button.danger {
166
+ color: #c55353;
167
+ }
168
+ .error-banner {
169
+ display: flex;
170
+ align-items: center;
171
+ gap: 8px;
172
+ background: #fff1ef;
173
+ border: 1px solid #f4d9d4;
174
+ border-radius: 7px;
175
+ padding: 11px;
176
+ color: #b85b51;
177
+ font-size: 12px;
178
+ margin-bottom: 15px;
179
+ }
180
+ .error-banner button {
181
+ margin-left: auto;
182
+ }
183
+ .overlay {
184
+ position: fixed;
185
+ inset: 0;
186
+ background: #192d4b45;
187
+ z-index: 70;
188
+ display: flex;
189
+ align-items: center;
190
+ justify-content: center;
191
+ padding: 20px;
192
+ backdrop-filter: blur(3px);
193
+ }
194
+ .dialog {
195
+ width: 460px;
196
+ max-width: 100%;
197
+ background: white;
198
+ border-radius: 13px;
199
+ box-shadow: 0 15px 70px #1d375630;
200
+ overflow: hidden;
201
+ max-height: 90vh;
202
+ overflow-y: auto;
203
+ }
204
+ .dialog-header {
205
+ display: flex;
206
+ justify-content: space-between;
207
+ align-items: center;
208
+ padding: 19px 22px;
209
+ border-bottom: 1px solid #edf1f5;
210
+ }
211
+ .dialog-body {
212
+ min-width: 0;
213
+ padding: 20px 22px;
214
+ display: flex;
215
+ flex-direction: column;
216
+ gap: 15px;
217
+ }
218
+ .dialog-body label {
219
+ display: flex;
220
+ flex-direction: column;
221
+ gap: 6px;
222
+ font-size: 12px;
223
+ color: #586b83;
224
+ }
225
+ .dialog-body > .muted {
226
+ overflow-wrap: anywhere;
227
+ }
228
+ .dialog-footer {
229
+ padding: 16px 22px;
230
+ border-top: 1px solid #edf1f5;
231
+ display: flex;
232
+ justify-content: flex-end;
233
+ gap: 9px;
234
+ }
235
+ .loading-spin {
236
+ animation: spin 1.2s linear infinite;
237
+ }
238
+ @keyframes spin {
239
+ to {
240
+ transform: rotate(360deg);
241
+ }
242
+ }
243
+ .tag.green {
244
+ color: #17715d;
245
+ }
246
+ .tag.orange {
247
+ color: #9a5b14;
248
+ }
249
+ .tag.red {
250
+ color: #a84339;
251
+ }
252
+ .tag.blue {
253
+ color: #315da9;
254
+ }
255
+ .tag {
256
+ color: #586b83;
257
+ }
258
+ .dialog-footer {
259
+ flex-wrap: wrap;
260
+ }
261
+ .button.primary { box-shadow: none; }
@@ -0,0 +1,35 @@
1
+ .ui-select { display: inline-flex; min-width: 0; max-width: 100%; vertical-align: middle; position: relative; }
2
+ .ui-select-trigger { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 34px; padding: 7px 10px; border: 1px solid #dfe6ef; border-radius: 8px; background: #fff; color: #334155; font: inherit; font-size: 12px; text-align: left; }
3
+ .ui-select-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4
+ .ui-select-trigger > svg { flex: none; color: #64748b; }
5
+ .ui-select-trigger:hover:not(:disabled) { border-color: #95b5f2; background: #f8faff; }
6
+ .ui-select-trigger:focus-visible, .ui-file-button:focus-visible, .ui-checkbox:focus-visible { outline: 2px solid #3169e5; outline-offset: 3px; }
7
+ .ui-select-trigger[aria-expanded="true"] { border-color: #95b5f2; }
8
+ .ui-select-trigger:disabled { opacity: .5; cursor: not-allowed; }
9
+ .ui-select-menu { position: fixed; z-index: 10000; box-sizing: border-box; width: max-content; max-width: calc(100vw - 16px); overflow-y: auto; padding: 4px; border: 1px solid #dfe6ef; border-radius: 9px; background: #fff; box-shadow: 0 8px 24px #19345124; color: #334155; font-size: 12px; }
10
+ .ui-select-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 32px; padding: 6px 8px; border-radius: 5px; cursor: pointer; }
11
+ .ui-select-option > span { min-width: 0; overflow-wrap: anywhere; }
12
+ .ui-select-option > svg { flex: none; }
13
+ .ui-select-option[data-active="true"] { background: #eff5ff; }
14
+ .ui-select-option[aria-selected="true"] { color: #245ac7; }
15
+ .ui-select-option[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
16
+ .ui-checkbox { display: inline-grid; place-content: center; flex: 0 0 18px; width: 18px; height: 18px; min-height: 18px; padding: 0; margin: 2px 0; border: 1px solid #a6b6ca; border-radius: 4px; background: #fff; color: #fff; cursor: pointer; vertical-align: middle; }
17
+ .ui-checkbox[aria-checked="true"] { background: #3169e5; border-color: #3169e5; }
18
+ .ui-checkbox:disabled { opacity: .45; cursor: not-allowed; }
19
+ .ui-checkbox:focus-visible, .ui-radio-option:focus-visible { outline: 2px solid #3169e5; outline-offset: 3px; }
20
+ .ui-radio-group { display: flex; flex-direction: column; gap: 8px; }
21
+ .ui-radio-option { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 12px; border: 1px solid #dfe6ef; border-radius: 6px; background: #fff; color: #334155; text-align: left; width: 100%; font: inherit; font-size: 13px; }
22
+ .ui-radio-option:hover:not(:disabled) { border-color: #95b5f2; }
23
+ .ui-radio-option[aria-checked="true"] { border-color: #3169e5; background: #f3f7ff; }
24
+ .ui-radio-option > span:last-child { min-width: 0; overflow-wrap: anywhere; }
25
+ .ui-radio-option small { display: block; margin-top: 4px; color: #657488; font-size: 12px; line-height: 1.5; }
26
+ .ui-radio-mark { display: grid; place-items: center; flex: 0 0 17px; height: 17px; margin-top: 2px; border: 1px solid #a6b6ca; border-radius: 50%; color: #3169e5; }
27
+ .ui-radio-option[aria-checked="true"] .ui-radio-mark { border-color: currentColor; }
28
+ .ui-radio-option[aria-checked="true"] .ui-radio-mark::after { content: ''; width: 0; height: 0; border: 4px solid currentColor; border-radius: 50%; }
29
+ .ui-file-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px; border: 1px dashed #bfcee2; border-radius: 10px; background: #f8faff; }
30
+ .ui-file-picker .ui-file-button { flex: none; }
31
+ .ui-file-name { min-width: 0; overflow-wrap: anywhere; color: #64748b; font-size: 12px; }
32
+ .dialog-body label > .ui-select, .task-history > .ui-select { width: 100%; }
33
+ @media (forced-colors: active) { .ui-checkbox[aria-checked="true"] { background: Highlight; color: HighlightText; border-color: Highlight; } .ui-radio-option[aria-checked="true"] { border-color: Highlight; } }
34
+
35
+ input.ui-select-value { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; clip-path: inset(50%); }
@@ -0,0 +1,2 @@
1
+ import './base.css';
2
+ export * from './Controls.js';
@@ -0,0 +1,2 @@
1
+ import './base.css';
2
+ export * from './Controls.js';
@@ -0,0 +1,107 @@
1
+ /** Explicit transport for a host-authenticated workspace, separate from capability sessions. */
2
+ export interface WorkspaceOptions {
3
+ baseUrl?: string;
4
+ fetch: typeof fetch;
5
+ }
6
+ /** Reuse this object to retry the same write intent explicitly. */
7
+ export interface WorkspaceIntent {
8
+ idempotencyKey?: string;
9
+ }
10
+ /** A human assessment of delivered work, not permission for a business operation. */
11
+ export interface TaskReviewInput {
12
+ expected_version: number;
13
+ decision: 'accepted' | 'changes_requested';
14
+ comment: string;
15
+ }
16
+ /** Versioned periodic work, with application-owned input kept opaque. */
17
+ export interface Schedule {
18
+ id: string;
19
+ agent_id: string;
20
+ prompt: string;
21
+ input: Record<string, unknown>;
22
+ trigger: {
23
+ type: 'interval';
24
+ every_seconds: number;
25
+ } | {
26
+ type: 'cron';
27
+ expression: string;
28
+ timezone: string;
29
+ };
30
+ ends_at: string;
31
+ enabled: boolean;
32
+ version: number;
33
+ overlap_policy: string;
34
+ misfire_policy: string;
35
+ last_run_at?: string | null;
36
+ }
37
+ /** Create a scoped client; the host supplies its CSRF-aware transport. */
38
+ export declare function createWorkspaceClient({ baseUrl, fetch: transport, }: WorkspaceOptions): {
39
+ request: <T = unknown>(path: string, init?: RequestInit) => Promise<T>;
40
+ raw: (path: string, init?: RequestInit) => Promise<Response>;
41
+ contentUrl: (path: string) => string;
42
+ catalog: {
43
+ get: <T = unknown>() => Promise<T>;
44
+ };
45
+ agents: {
46
+ list: <T = unknown>() => Promise<T>;
47
+ create: <T = unknown>(body: unknown, intent?: WorkspaceIntent) => Promise<T>;
48
+ update: <T = unknown>(key: string, body: unknown, intent?: WorkspaceIntent) => Promise<T>;
49
+ };
50
+ skills: {
51
+ list: <T = unknown>() => Promise<T>;
52
+ import: <T = unknown>(body: unknown, intent?: WorkspaceIntent) => Promise<T>;
53
+ get: <T = unknown>(key: string) => Promise<T>;
54
+ };
55
+ connectors: {
56
+ tools: <T = unknown>(body: unknown, intent?: WorkspaceIntent) => Promise<T>;
57
+ list: <T = unknown>() => Promise<T>;
58
+ create: <T = unknown>(body: unknown, intent?: WorkspaceIntent) => Promise<T>;
59
+ update: <T = unknown>(key: string, body: unknown, intent?: WorkspaceIntent) => Promise<T>;
60
+ };
61
+ tasks: {
62
+ review: <T = unknown>(key: string, body: TaskReviewInput, intent?: WorkspaceIntent) => Promise<T>;
63
+ actionResult: (key: string, action: string, body: unknown, intent?: WorkspaceIntent) => Promise<unknown>;
64
+ get: <T = unknown>(key: string) => Promise<T>;
65
+ message: <T = unknown>(key: string, body: unknown, intent?: WorkspaceIntent) => Promise<T>;
66
+ cancel: <T = unknown>(key: string, intent?: WorkspaceIntent) => Promise<T>;
67
+ retry: <T = unknown>(key: string, intent?: WorkspaceIntent) => Promise<T>;
68
+ answer: <T = unknown>(key: string, body: unknown, intent?: WorkspaceIntent) => Promise<T>;
69
+ decide: <T = unknown>(key: string, proposal: string, decision: "confirm" | "reject", expected_version: number, intent?: WorkspaceIntent) => Promise<T>;
70
+ list: <T = unknown>() => Promise<T>;
71
+ create: <T = unknown>(body: unknown, intent?: WorkspaceIntent) => Promise<T>;
72
+ update: <T = unknown>(key: string, body: unknown, intent?: WorkspaceIntent) => Promise<T>;
73
+ };
74
+ files: {
75
+ upload: (file: Blob, name: string, intent?: WorkspaceIntent) => Promise<{
76
+ id: string;
77
+ }>;
78
+ delete: (key: string, intent?: WorkspaceIntent) => Promise<unknown>;
79
+ listWorkspace: <T = unknown>() => Promise<T>;
80
+ uploadWorkspace: <T = unknown>(file: Blob, name: string, relativePath?: string, intent?: WorkspaceIntent) => Promise<T>;
81
+ deleteWorkspace: (key: string, intent?: WorkspaceIntent) => Promise<unknown>;
82
+ contentUrl: (path: string) => string;
83
+ };
84
+ schedules: {
85
+ runNow: (key: string, expected_version: number, intent?: WorkspaceIntent) => Promise<unknown>;
86
+ history: <T = unknown>(key: string) => Promise<T>;
87
+ list: <T = unknown>() => Promise<T>;
88
+ create: <T = unknown>(body: unknown, intent?: WorkspaceIntent) => Promise<T>;
89
+ update: <T = unknown>(key: string, body: unknown, intent?: WorkspaceIntent) => Promise<T>;
90
+ };
91
+ contexts: {
92
+ publish: <T = unknown>(body: unknown, intent?: WorkspaceIntent) => Promise<T>;
93
+ };
94
+ conversations: {
95
+ open: <T = unknown>(body: unknown, intent?: WorkspaceIntent) => Promise<T>;
96
+ send: <T = unknown>(key: string, body: unknown, intent?: WorkspaceIntent) => Promise<T>;
97
+ };
98
+ knowledge: {
99
+ search: <T = unknown>(query: string) => Promise<T>;
100
+ };
101
+ notifications: {
102
+ list: <T = unknown>() => Promise<T>;
103
+ read: (key: string, intent?: WorkspaceIntent) => Promise<unknown>;
104
+ };
105
+ };
106
+ /** Host workspace client with application-neutral payloads. */
107
+ export type WorkspaceClient = ReturnType<typeof createWorkspaceClient>;
@@ -0,0 +1,139 @@
1
+ /** Create a scoped client; the host supplies its CSRF-aware transport. */
2
+ export function createWorkspaceClient({ baseUrl = '/api/platform', fetch: transport, }) {
3
+ const origin = typeof location === 'undefined' ? 'http://localhost' : location.origin;
4
+ const base = new URL(baseUrl, origin);
5
+ if (base.origin !== origin ||
6
+ base.search ||
7
+ base.hash ||
8
+ base.username ||
9
+ base.password ||
10
+ !/^\/api\/platform\/?$/.test(base.pathname))
11
+ throw new Error('Invalid workspace API URL');
12
+ const prefix = base.pathname.replace(/\/$/, '');
13
+ function url(path) {
14
+ const relative = path.startsWith(prefix + '/') ? path.slice(prefix.length) : path;
15
+ if (!relative.startsWith('/') ||
16
+ relative.startsWith('//') ||
17
+ /(?:^|\/)\.\.?(?:\/|$)|\\|%2e|%2f|%5c/i.test(relative.split('?')[0]) ||
18
+ relative.startsWith('/api/'))
19
+ throw new Error('Invalid platform resource path');
20
+ return prefix + relative;
21
+ }
22
+ async function raw(path, init) {
23
+ const address = url(path);
24
+ if (init && !['GET', 'HEAD'].includes((init.method ?? 'GET').toUpperCase())) {
25
+ const headers = new Headers(init.headers);
26
+ if (!headers.has('Idempotency-Key'))
27
+ headers.set('Idempotency-Key', crypto.randomUUID());
28
+ init.headers = headers;
29
+ }
30
+ const response = await transport(address, {
31
+ ...init,
32
+ credentials: 'same-origin',
33
+ redirect: 'error',
34
+ cache: 'no-store',
35
+ });
36
+ if (!response.ok) {
37
+ const error = await response.json().catch(() => ({}));
38
+ throw new Error(typeof error.detail === 'string'
39
+ ? error.detail
40
+ : typeof error.error?.message === 'string'
41
+ ? error.error.message
42
+ : `Request could not be completed (${response.status})`);
43
+ }
44
+ return response;
45
+ }
46
+ async function request(path, init) {
47
+ const response = await raw(path, init);
48
+ return response.status === 204 ? null : response.json();
49
+ }
50
+ function write(path, body, method = 'POST', intent = {}) {
51
+ intent.idempotencyKey ??= crypto.randomUUID();
52
+ return request(path, {
53
+ method,
54
+ headers: {
55
+ 'Content-Type': 'application/json',
56
+ 'Idempotency-Key': intent.idempotencyKey,
57
+ },
58
+ body: JSON.stringify(body),
59
+ });
60
+ }
61
+ function upload(path, file, intent = {}) {
62
+ intent.idempotencyKey ??= crypto.randomUUID();
63
+ return request(path, {
64
+ method: 'POST',
65
+ headers: {
66
+ 'Content-Type': 'application/octet-stream',
67
+ 'Idempotency-Key': intent.idempotencyKey,
68
+ },
69
+ body: file,
70
+ });
71
+ }
72
+ function remove(path, intent = {}) {
73
+ intent.idempotencyKey ??= crypto.randomUUID();
74
+ return request(path, {
75
+ method: 'DELETE',
76
+ headers: { 'Idempotency-Key': intent.idempotencyKey },
77
+ });
78
+ }
79
+ const id = (value) => encodeURIComponent(value);
80
+ const crud = (path) => ({
81
+ list: () => request(path),
82
+ create: (body, intent) => write(path, body, 'POST', intent),
83
+ update: (key, body, intent) => write(`${path}/${id(key)}`, body, 'PATCH', intent),
84
+ });
85
+ return {
86
+ request,
87
+ raw,
88
+ contentUrl: url,
89
+ catalog: { get: () => request('/catalog') },
90
+ agents: crud('/agents'),
91
+ skills: {
92
+ list: () => request('/skills'),
93
+ import: (body, intent) => write('/skills/import', body, 'POST', intent),
94
+ get: (key) => request(`/skills/${id(key)}`),
95
+ },
96
+ connectors: {
97
+ ...crud('/mcp-servers'),
98
+ tools: (body, intent) => write('/mcp-servers/test', body, 'POST', intent),
99
+ },
100
+ tasks: {
101
+ ...crud('/tasks'),
102
+ review: (key, body, intent) => write(`/tasks/${id(key)}/reviews`, body, 'POST', intent),
103
+ actionResult: (key, action, body, intent) => write(`/tasks/${id(key)}/actions/${id(action)}`, body, 'POST', intent),
104
+ get: (key) => request(`/tasks/${id(key)}`),
105
+ message: (key, body, intent) => write(`/tasks/${id(key)}/messages`, body, 'POST', intent),
106
+ cancel: (key, intent) => write(`/tasks/${id(key)}/cancel`, {}, 'POST', intent),
107
+ retry: (key, intent) => write(`/tasks/${id(key)}/retry`, {}, 'POST', intent),
108
+ answer: (key, body, intent) => write(`/tasks/${id(key)}/input`, body, 'POST', intent),
109
+ decide: (key, proposal, decision, expected_version, intent) => write(`/tasks/${id(key)}/proposals/${id(proposal)}/${decision}`, { expected_version }, 'POST', intent),
110
+ },
111
+ files: {
112
+ upload: (file, name, intent) => upload(`/attachments?filename=${id(name)}`, file, intent),
113
+ delete: (key, intent) => remove(`/attachments/${id(key)}`, intent),
114
+ listWorkspace: () => request('/workspace/files'),
115
+ uploadWorkspace: (file, name, relativePath, intent) => upload(`/workspace/files?filename=${id(name)}${relativePath ? `&relative_path=${id(relativePath)}` : ''}`, file, intent),
116
+ deleteWorkspace: (key, intent) => remove(`/workspace/files/${id(key)}`, intent),
117
+ contentUrl: url,
118
+ },
119
+ schedules: {
120
+ ...crud('/schedules'),
121
+ runNow: (key, expected_version, intent) => write(`/schedules/${id(key)}/run-now`, { expected_version }, 'POST', intent),
122
+ history: (key) => request(`/schedules/${id(key)}/occurrences`),
123
+ },
124
+ contexts: {
125
+ publish: (body, intent) => write('/contexts', body, 'POST', intent),
126
+ },
127
+ conversations: {
128
+ open: (body, intent) => write('/conversations', body, 'POST', intent),
129
+ send: (key, body, intent) => write(`/conversations/${id(key)}/messages`, body, 'POST', intent),
130
+ },
131
+ knowledge: {
132
+ search: (query) => request(`/knowledge?query=${id(query)}`),
133
+ },
134
+ notifications: {
135
+ list: () => request('/notifications'),
136
+ read: (key, intent) => write(`/notifications/${id(key)}/read`, {}, 'POST', intent),
137
+ },
138
+ };
139
+ }
package/package.json CHANGED
@@ -1,6 +1,89 @@
1
1
  {
2
2
  "name": "@field-studio/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Field Studio clients for browsers and Node.js, with React integration and components",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/apemost/field-studio.git",
9
+ "directory": "sdk/typescript/packages/sdk"
10
+ },
11
+ "engines": {
12
+ "node": ">=24"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "registry": "https://registry.npmjs.org/"
17
+ },
18
+ "type": "module",
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js"
26
+ },
27
+ "./node": {
28
+ "types": "./dist/node/index.d.ts",
29
+ "node": "./dist/node/index.js"
30
+ },
31
+ "./react": {
32
+ "types": "./dist/react/index.d.ts",
33
+ "import": "./dist/react/index.js"
34
+ },
35
+ "./react/assistant": {
36
+ "types": "./dist/react/assistant/index.d.ts",
37
+ "import": "./dist/react/assistant/index.js"
38
+ },
39
+ "./react/agent": {
40
+ "types": "./dist/react/agent/index.d.ts",
41
+ "import": "./dist/react/agent/index.js"
42
+ },
43
+ "./react/auth": {
44
+ "types": "./dist/react/auth/index.d.ts",
45
+ "import": "./dist/react/auth/index.js"
46
+ },
47
+ "./react/ui": {
48
+ "types": "./dist/react/ui/index.d.ts",
49
+ "import": "./dist/react/ui/index.js"
50
+ }
51
+ },
52
+ "peerDependencies": {
53
+ "lucide-react": "^0.468.0",
54
+ "react": "^19.0.0",
55
+ "react-dom": "^19.0.0"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "lucide-react": {
59
+ "optional": true
60
+ },
61
+ "react": {
62
+ "optional": true
63
+ },
64
+ "react-dom": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "devDependencies": {
69
+ "@testing-library/jest-dom": "^6.0.0",
70
+ "@testing-library/react": "^16.0.0",
71
+ "@testing-library/user-event": "^14.0.0",
72
+ "@types/node": "^24.0.0",
73
+ "@types/react": "^19.0.0",
74
+ "@types/react-dom": "^19.0.0",
75
+ "@vitejs/plugin-react": "^5.0.0",
76
+ "jsdom": "^27.0.0",
77
+ "lucide-react": "^0.468.0",
78
+ "react": "^19.0.0",
79
+ "react-dom": "^19.0.0",
80
+ "typescript": "^5.9.0",
81
+ "vite": "^7.0.0",
82
+ "vitest": "^3.2.0"
83
+ },
84
+ "scripts": {
85
+ "build": "tsc -p tsconfig.build.json && node ../../scripts/copy-component-styles.mjs",
86
+ "typecheck": "tsc --noEmit",
87
+ "test": "vitest run && vitest run --config vitest.react.config.ts && node --test test/*.test.mjs"
88
+ }
6
89
  }