@harnesys/sdk 1.2.0 → 1.3.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.
@@ -12,10 +12,10 @@ export function createHostClient(channel, getMeta) {
12
12
  if (!spec) {
13
13
  throw new Error(`method '${entry.method}' is not in the protocol map`);
14
14
  }
15
- const parsedParams = spec.params.parse({
16
- ...params,
15
+ const parsedParams = {
16
+ ...spec.params.parse(params),
17
17
  _meta: getMeta(),
18
- });
18
+ };
19
19
  const raw = await channel.request(entry.method, parsedParams, options?.signal);
20
20
  return spec.result ? spec.result.parse(raw) : raw;
21
21
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type AddonAccounts, type AddonBridge, type AddonConfig, type AddonContext, type AddonDb, type AddonEvents, type AddonFileChunk, type AddonFileStat, type AddonFiles, type AddonFileWriteResult, type AddonHttp, type AddonLog, type AddonLogLevel, type AddonProgress, type AddonRuns, type AddonSecrets, type AddonSkills, type AddonThreads, type AddonTriggerField, type AddonTriggers, type AddonTriggerTarget, type AddonUsage, type AddonWorkers, createAddonContext, type DbRow, type DbStatement, type DbWriteResult, type SqlParam, } from './addon-context-factory.ts';
1
+ export { type AddonAccounts, type AddonBridge, type AddonConfig, type AddonContext, type AddonDb, type AddonEvents, type AddonFileChunk, type AddonFileStat, type AddonFiles, type AddonFileWriteResult, type AddonHttp, type AddonLog, type AddonLogLevel, type AddonProgress, type AddonRuns, type AddonSecrets, type AddonSkills, type AddonThreads, type AddonTriggerField, type AddonTriggers, type AddonTriggerTarget, type AddonTriggerWorkspace, type AddonUsage, type AddonWorkers, createAddonContext, type DbRow, type DbStatement, type DbWriteResult, type SqlParam, } from './addon-context-factory.ts';
2
2
  export { type AddonDefinition, defineAddon, deriveHandlers, type HookHandler, type JobHandler, type LifecycleHandlers, type NotificationHandlers, type ResolvedAddonDefinition, type RouteHandler, type SourceBackendHandlers, type ToolHandler, type TransportHandlers, type TriggerPair, type WorkerPair, } from './define-addon.ts';
3
3
  export { CONFIG_SCHEMA_VERSION, type ConfigDescriptor, ConfigDescriptorSchema, configFamily, } from './families/config.ts';
4
4
  export { CONTENT_SCHEMA_VERSION, type ContentDescriptor, ContentDescriptorSchema, contentFamily, } from './families/content.ts';
@@ -78,7 +78,11 @@ export async function startAddonProcess(options) {
78
78
  function replyError(id, error) {
79
79
  const data = isAddonError(error)
80
80
  ? error.toData()
81
- : { reason: 'internal', retryable: false };
81
+ : {
82
+ reason: 'internal',
83
+ retryable: false,
84
+ detail: error instanceof Error ? error.message : String(error),
85
+ };
82
86
  if (!isAddonError(error)) {
83
87
  wiring.stderr.write(`addon request failed: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`);
84
88
  }
@@ -172,6 +172,7 @@ export declare const protocolMap: {
172
172
  label: z.ZodOptional<z.ZodString>;
173
173
  config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
174
174
  target: z.ZodOptional<z.ZodUnknown>;
175
+ instructions: z.ZodOptional<z.ZodString>;
175
176
  _meta: z.ZodObject<{
176
177
  correlationId: z.ZodString;
177
178
  deadline: z.ZodNullable<z.ZodNumber>;
@@ -803,6 +804,24 @@ export declare const protocolMap: {
803
804
  threadId: z.ZodString;
804
805
  agentId: z.ZodString;
805
806
  modeId: z.ZodOptional<z.ZodString>;
807
+ workspace: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
808
+ kind: z.ZodLiteral<"inherit">;
809
+ }, z.core.$strip>, z.ZodObject<{
810
+ kind: z.ZodLiteral<"sandbox">;
811
+ }, z.core.$strip>, z.ZodObject<{
812
+ kind: z.ZodLiteral<"folder">;
813
+ path: z.ZodString;
814
+ hostId: z.ZodOptional<z.ZodString>;
815
+ }, z.core.$strip>, z.ZodObject<{
816
+ kind: z.ZodLiteral<"source">;
817
+ sourceId: z.ZodString;
818
+ subpath: z.ZodOptional<z.ZodString>;
819
+ }, z.core.$strip>, z.ZodObject<{
820
+ kind: z.ZodLiteral<"worktree">;
821
+ sourceId: z.ZodString;
822
+ worktreeId: z.ZodString;
823
+ subpath: z.ZodOptional<z.ZodString>;
824
+ }, z.core.$strip>], "kind">>;
806
825
  }, z.core.$strip>;
807
826
  instructions: z.ZodOptional<z.ZodString>;
808
827
  }, z.core.$strip>, z.ZodObject<{
@@ -816,6 +835,24 @@ export declare const protocolMap: {
816
835
  threadId: z.ZodString;
817
836
  agentId: z.ZodString;
818
837
  modeId: z.ZodOptional<z.ZodString>;
838
+ workspace: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
839
+ kind: z.ZodLiteral<"inherit">;
840
+ }, z.core.$strip>, z.ZodObject<{
841
+ kind: z.ZodLiteral<"sandbox">;
842
+ }, z.core.$strip>, z.ZodObject<{
843
+ kind: z.ZodLiteral<"folder">;
844
+ path: z.ZodString;
845
+ hostId: z.ZodOptional<z.ZodString>;
846
+ }, z.core.$strip>, z.ZodObject<{
847
+ kind: z.ZodLiteral<"source">;
848
+ sourceId: z.ZodString;
849
+ subpath: z.ZodOptional<z.ZodString>;
850
+ }, z.core.$strip>, z.ZodObject<{
851
+ kind: z.ZodLiteral<"worktree">;
852
+ sourceId: z.ZodString;
853
+ worktreeId: z.ZodString;
854
+ subpath: z.ZodOptional<z.ZodString>;
855
+ }, z.core.$strip>], "kind">>;
819
856
  }, z.core.$strip>>;
820
857
  instructions: z.ZodOptional<z.ZodString>;
821
858
  enabled: z.ZodOptional<z.ZodBoolean>;
@@ -859,6 +896,7 @@ export declare const protocolMap: {
859
896
  mimeType: z.ZodString;
860
897
  extension: z.ZodString;
861
898
  }, z.core.$strip>>;
899
+ url: z.ZodOptional<z.ZodString>;
862
900
  }, z.core.$strip>>;
863
901
  nextPageToken: z.ZodOptional<z.ZodString>;
864
902
  }, z.core.$strip>, "host-to-addon">;
@@ -898,6 +936,7 @@ export declare const protocolMap: {
898
936
  mimeType: z.ZodString;
899
937
  extension: z.ZodString;
900
938
  }, z.core.$strip>>;
939
+ url: z.ZodOptional<z.ZodString>;
901
940
  }, z.core.$strip>;
902
941
  }, z.core.$strip>, "host-to-addon">;
903
942
  'source.download': MethodSpec<z.ZodObject<{
@@ -38,6 +38,7 @@ export const protocolMap = {
38
38
  label: str.optional(),
39
39
  config: z.record(z.string(), z.unknown()),
40
40
  target: z.unknown().optional(),
41
+ instructions: str.optional(),
41
42
  })
42
43
  .extend({ _meta: CallMetaSchema }), empty, 'trigger'),
43
44
  'trigger.stop': hostMethod(z
@@ -113,6 +113,24 @@ export declare const orgServiceMethods: {
113
113
  threadId: z.ZodString;
114
114
  agentId: z.ZodString;
115
115
  modeId: z.ZodOptional<z.ZodString>;
116
+ workspace: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
117
+ kind: z.ZodLiteral<"inherit">;
118
+ }, z.core.$strip>, z.ZodObject<{
119
+ kind: z.ZodLiteral<"sandbox">;
120
+ }, z.core.$strip>, z.ZodObject<{
121
+ kind: z.ZodLiteral<"folder">;
122
+ path: z.ZodString;
123
+ hostId: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>, z.ZodObject<{
125
+ kind: z.ZodLiteral<"source">;
126
+ sourceId: z.ZodString;
127
+ subpath: z.ZodOptional<z.ZodString>;
128
+ }, z.core.$strip>, z.ZodObject<{
129
+ kind: z.ZodLiteral<"worktree">;
130
+ sourceId: z.ZodString;
131
+ worktreeId: z.ZodString;
132
+ subpath: z.ZodOptional<z.ZodString>;
133
+ }, z.core.$strip>], "kind">>;
116
134
  }, z.core.$strip>;
117
135
  instructions: z.ZodOptional<z.ZodString>;
118
136
  }, z.core.$strip>, z.ZodObject<{
@@ -126,6 +144,24 @@ export declare const orgServiceMethods: {
126
144
  threadId: z.ZodString;
127
145
  agentId: z.ZodString;
128
146
  modeId: z.ZodOptional<z.ZodString>;
147
+ workspace: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
148
+ kind: z.ZodLiteral<"inherit">;
149
+ }, z.core.$strip>, z.ZodObject<{
150
+ kind: z.ZodLiteral<"sandbox">;
151
+ }, z.core.$strip>, z.ZodObject<{
152
+ kind: z.ZodLiteral<"folder">;
153
+ path: z.ZodString;
154
+ hostId: z.ZodOptional<z.ZodString>;
155
+ }, z.core.$strip>, z.ZodObject<{
156
+ kind: z.ZodLiteral<"source">;
157
+ sourceId: z.ZodString;
158
+ subpath: z.ZodOptional<z.ZodString>;
159
+ }, z.core.$strip>, z.ZodObject<{
160
+ kind: z.ZodLiteral<"worktree">;
161
+ sourceId: z.ZodString;
162
+ worktreeId: z.ZodString;
163
+ subpath: z.ZodOptional<z.ZodString>;
164
+ }, z.core.$strip>], "kind">>;
129
165
  }, z.core.$strip>>;
130
166
  instructions: z.ZodOptional<z.ZodString>;
131
167
  enabled: z.ZodOptional<z.ZodBoolean>;
@@ -2,6 +2,24 @@ import { z } from 'zod';
2
2
  import { addonMethod } from "./method-spec.js";
3
3
  import { TriggerFireOutcomeSchema } from "./shared.js";
4
4
  const str = z.string().min(1);
5
+ const TriggerWorkspaceSchema = z.discriminatedUnion('kind', [
6
+ z.object({ kind: z.literal('inherit') }),
7
+ z.object({ kind: z.literal('sandbox') }),
8
+ z.object({ kind: z.literal('folder'), path: str, hostId: str.optional() }),
9
+ z.object({ kind: z.literal('source'), sourceId: str, subpath: str.optional() }),
10
+ z.object({
11
+ kind: z.literal('worktree'),
12
+ sourceId: str,
13
+ worktreeId: str,
14
+ subpath: str.optional(),
15
+ }),
16
+ ]);
17
+ const TriggerTargetSchema = z.object({
18
+ threadId: str,
19
+ agentId: str,
20
+ modeId: str.optional(),
21
+ workspace: TriggerWorkspaceSchema.optional(),
22
+ });
5
23
  /** Read/action methods over org-scoped thread, run, usage and skill state (§6.4). */
6
24
  export const orgServiceMethods = {
7
25
  'runs.list': addonMethod(z.object({ threadId: str, status: z.string().optional() }), z.object({
@@ -82,24 +100,14 @@ export const orgServiceMethods = {
82
100
  kind: str,
83
101
  label: str,
84
102
  config: z.record(z.string(), z.unknown()).default({}),
85
- target: z.object({
86
- threadId: str,
87
- agentId: str,
88
- modeId: str.optional(),
89
- }),
103
+ target: TriggerTargetSchema,
90
104
  instructions: str.optional(),
91
105
  }), z.object({ instanceId: str }), 'trigger'),
92
106
  'triggers.update': addonMethod(z.object({
93
107
  instanceId: str,
94
108
  label: str.optional(),
95
109
  config: z.record(z.string(), z.unknown()).optional(),
96
- target: z
97
- .object({
98
- threadId: str,
99
- agentId: str,
100
- modeId: str.optional(),
101
- })
102
- .optional(),
110
+ target: TriggerTargetSchema.optional(),
103
111
  instructions: str.optional(),
104
112
  enabled: z.boolean().optional(),
105
113
  }), z.object({ instanceId: str }), 'trigger'),
@@ -170,6 +170,7 @@ export declare const CloudRemoteEntrySchema: z.ZodObject<{
170
170
  mimeType: z.ZodString;
171
171
  extension: z.ZodString;
172
172
  }, z.core.$strip>>;
173
+ url: z.ZodOptional<z.ZodString>;
173
174
  }, z.core.$strip>;
174
175
  export type CloudRemoteEntryWire = z.infer<typeof CloudRemoteEntrySchema>;
175
176
  export type CloudRemoteExportWire = z.infer<typeof CloudRemoteExportSchema>;
@@ -194,6 +195,7 @@ export declare const SourceListResultSchema: z.ZodObject<{
194
195
  mimeType: z.ZodString;
195
196
  extension: z.ZodString;
196
197
  }, z.core.$strip>>;
198
+ url: z.ZodOptional<z.ZodString>;
197
199
  }, z.core.$strip>>;
198
200
  nextPageToken: z.ZodOptional<z.ZodString>;
199
201
  }, z.core.$strip>;
@@ -217,6 +219,7 @@ export declare const SourceStatResultSchema: z.ZodObject<{
217
219
  mimeType: z.ZodString;
218
220
  extension: z.ZodString;
219
221
  }, z.core.$strip>>;
222
+ url: z.ZodOptional<z.ZodString>;
220
223
  }, z.core.$strip>;
221
224
  }, z.core.$strip>;
222
225
  export declare const SourceReadParamsSchema: z.ZodObject<{
@@ -82,6 +82,8 @@ export const CloudRemoteEntrySchema = z.object({
82
82
  modifiedAt: z.string().min(1).optional(),
83
83
  mimeType: z.string().min(1).optional(),
84
84
  export: CloudRemoteExportSchema.optional(),
85
+ /** HTTPS clone URL; required on entries of `mount: 'git'` source kinds. */
86
+ url: z.string().min(1).optional(),
85
87
  });
86
88
  const sourceSelector = {
87
89
  sourceKind: z.string().min(1),
@@ -41,6 +41,7 @@ export declare const sourceMethods: {
41
41
  mimeType: z.ZodString;
42
42
  extension: z.ZodString;
43
43
  }, z.core.$strip>>;
44
+ url: z.ZodOptional<z.ZodString>;
44
45
  }, z.core.$strip>>;
45
46
  nextPageToken: z.ZodOptional<z.ZodString>;
46
47
  }, z.core.$strip>, "host-to-addon">;
@@ -80,6 +81,7 @@ export declare const sourceMethods: {
80
81
  mimeType: z.ZodString;
81
82
  extension: z.ZodString;
82
83
  }, z.core.$strip>>;
84
+ url: z.ZodOptional<z.ZodString>;
83
85
  }, z.core.$strip>;
84
86
  }, z.core.$strip>, "host-to-addon">;
85
87
  'source.download': import("./method-spec.ts").MethodSpec<z.ZodObject<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harnesys/sdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Add-on SDK for Harnesys: manifest, contributions, JSON-RPC protocol, permissions, defineAddon, host client and a testing fake host.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,6 +41,7 @@ export type {
41
41
  AddonTriggerField,
42
42
  AddonTriggers,
43
43
  AddonTriggerTarget,
44
+ AddonTriggerWorkspace,
44
45
  AddonUsage,
45
46
  AddonWorkers,
46
47
  DbRow,
@@ -190,10 +190,18 @@ export interface AddonSkills {
190
190
  }): Promise<Array<{ id: string; name: string; description: string | null; source: string }>>;
191
191
  }
192
192
 
193
+ export type AddonTriggerWorkspace =
194
+ | { kind: 'inherit' }
195
+ | { kind: 'sandbox' }
196
+ | { kind: 'folder'; path: string; hostId?: string }
197
+ | { kind: 'source'; sourceId: string; subpath?: string }
198
+ | { kind: 'worktree'; sourceId: string; worktreeId: string; subpath?: string };
199
+
193
200
  export interface AddonTriggerTarget {
194
201
  threadId: string;
195
202
  agentId: string;
196
203
  modeId?: string;
204
+ workspace?: AddonTriggerWorkspace;
197
205
  }
198
206
 
199
207
  export interface AddonTriggerField {
@@ -59,7 +59,7 @@ export interface SourceBackendHandlers {
59
59
  params: Omit<HostMethodParams<'source.stat'>, '_meta'>,
60
60
  ctx: AddonContext,
61
61
  ): HostMethodResult<'source.stat'> | Promise<HostMethodResult<'source.stat'>>;
62
- download(
62
+ download?(
63
63
  params: Omit<HostMethodParams<'source.download'>, '_meta'>,
64
64
  ctx: AddonContext,
65
65
  ): HostMethodResult<'source.download'> | Promise<HostMethodResult<'source.download'>>;
@@ -159,11 +159,11 @@ function sourceHandlerNames(sources: Record<string, SourceBackendHandlers> | und
159
159
  if (sources === undefined || Object.keys(sources).length === 0) {
160
160
  return [];
161
161
  }
162
- const names = ['source.list', 'source.stat', 'source.download'];
162
+ const names = ['source.list', 'source.stat'];
163
163
  const implementations = Object.values(sources);
164
164
  const anyOp = (op: keyof SourceBackendHandlers): boolean =>
165
165
  implementations.some((backend) => backend[op] !== undefined);
166
- for (const op of ['upload', 'mkdir', 'remove', 'export'] as const) {
166
+ for (const op of ['download', 'upload', 'mkdir', 'remove', 'export'] as const) {
167
167
  if (anyOp(op)) {
168
168
  names.push(`source.${op}`);
169
169
  }
@@ -8,6 +8,7 @@ export type FieldType =
8
8
  | 'select'
9
9
  | 'number'
10
10
  | 'boolean'
11
+ | 'file'
11
12
  | 'group';
12
13
 
13
14
  export type FieldValue = string | number | boolean | null;
@@ -17,6 +18,8 @@ export interface FieldOption {
17
18
  label: string;
18
19
  /** Hint shown for the currently selected option. */
19
20
  help?: string;
21
+ /** Group label used by multi-value pickers that render grouped panels. */
22
+ group?: string;
20
23
  }
21
24
 
22
25
  /** Conditional visibility: show the field only when `values[key]` matches. */
@@ -43,12 +46,16 @@ export type FieldOptionsFrom =
43
46
  route: string;
44
47
  /** Field keys passed to the route as query params. */
45
48
  dependsOn?: string[];
49
+ /** Static query params always sent to the route alongside `dependsOn` values. */
50
+ params?: Record<string, string>;
46
51
  /** Response body key holding the rows. Defaults to `rows`. */
47
52
  listKey?: string;
48
53
  /** Row field used as the option value. */
49
54
  valueKey: string;
50
55
  /** Row field used as the option label. Defaults to `valueKey`. */
51
56
  labelKey?: string;
57
+ /** Row field used to group options in multi-value pickers. */
58
+ groupKey?: string;
52
59
  }
53
60
  | { kind: 'connections' }
54
61
  | { kind: 'agents' };
@@ -89,6 +96,7 @@ export const FieldTypeSchema = z.enum([
89
96
  'select',
90
97
  'number',
91
98
  'boolean',
99
+ 'file',
92
100
  'group',
93
101
  ]);
94
102
 
@@ -98,6 +106,7 @@ export const FieldOptionSchema = z.object({
98
106
  value: z.string(),
99
107
  label: z.string(),
100
108
  help: z.string().optional(),
109
+ group: z.string().optional(),
101
110
  });
102
111
 
103
112
  export const FieldVisibleWhenSchema = z.object({
@@ -116,9 +125,11 @@ export const FieldOptionsFromSchema: z.ZodType<FieldOptionsFrom> = z.union([
116
125
  kind: z.literal('addonRoute'),
117
126
  route: z.string().min(1),
118
127
  dependsOn: z.array(z.string().min(1)).optional(),
128
+ params: z.record(z.string(), z.string()).optional(),
119
129
  listKey: z.string().min(1).optional(),
120
130
  valueKey: z.string().min(1),
121
131
  labelKey: z.string().min(1).optional(),
132
+ groupKey: z.string().min(1).optional(),
122
133
  }),
123
134
  z.object({ kind: z.literal('connections') }),
124
135
  z.object({ kind: z.literal('agents') }),
@@ -8,6 +8,13 @@ export interface SourceKindDescriptor {
8
8
  id: string;
9
9
  title: L10n;
10
10
  connection?: string;
11
+ /**
12
+ * What a source attached from this kind is. `cloud` (default) mirrors files
13
+ * through the add-on backend (`source.download`/`upload`). `git` attaches a
14
+ * core git source: entries must carry `url` (an HTTPS clone URL) and the
15
+ * add-on only needs `source.list`/`source.stat`.
16
+ */
17
+ mount?: 'cloud' | 'git';
11
18
  supportsRootMount?: boolean;
12
19
  supportsSearch?: boolean;
13
20
  rootTitle?: string;
@@ -17,6 +24,7 @@ export const SourceKindDescriptorSchema = z.object({
17
24
  id: z.string().min(1),
18
25
  title: L10nSchema,
19
26
  connection: z.string().min(1).optional(),
27
+ mount: z.enum(['cloud', 'git']).optional(),
20
28
  supportsRootMount: z.boolean().optional(),
21
29
  supportsSearch: z.boolean().optional(),
22
30
  rootTitle: z.string().min(1).optional(),
@@ -17,12 +17,41 @@ export interface Column {
17
17
  format: 'text' | 'datetime' | 'number' | 'badge' | 'link' | 'copy';
18
18
  }
19
19
 
20
+ export interface TableFilter {
21
+ key: string;
22
+ label: L10n;
23
+ /** Static filter options; `optionsFrom` takes precedence when both are set. */
24
+ options?: { value: string; label: string }[];
25
+ /** Options resolved from an add-on-owned GET route. */
26
+ optionsFrom?: { route: string; valueKey: string; labelKey?: string };
27
+ }
28
+
29
+ export interface FormDialogAction {
30
+ id: string;
31
+ label: L10n;
32
+ route: RouteRef;
33
+ confirm?: L10n;
34
+ destructive?: boolean;
35
+ }
36
+
20
37
  export interface Action {
21
38
  id: string;
22
39
  label: L10n;
23
40
  route: RouteRef;
24
41
  confirm?: L10n;
25
42
  destructive?: boolean;
43
+ /** Render as a switch bound to `checkedKey`, or as a modal form over `fields`. */
44
+ kind?: 'switch' | 'form';
45
+ /** Row field holding the switch state; requires `kind: 'switch'`. */
46
+ checkedKey?: string;
47
+ /** Form fields for the modal; requires `kind: 'form'`. */
48
+ fields?: FieldSpec[];
49
+ /** Maps form field keys to row keys for initial values; requires `kind: 'form'`. */
50
+ prefill?: Record<string, string>;
51
+ /** Extra footer buttons inside the `kind: 'form'` dialog (e.g. test, delete). */
52
+ formActions?: FormDialogAction[];
53
+ /** Header master switch POSTs this route with `{ enabled }` to set every row in the filter context. */
54
+ batchRoute?: RouteRef;
26
55
  }
27
56
 
28
57
  export type ViewSection =
@@ -40,8 +69,25 @@ export type ViewSection =
40
69
  columns: Column[];
41
70
  rowActions?: Action[];
42
71
  pageSize?: number;
72
+ /** Render checkboxes and enable `selectionActions` on selected rows. */
73
+ selectable?: boolean;
74
+ /** Bulk actions POSTed once with `{ ids }` of the selected rows. */
75
+ selectionActions?: Action[];
76
+ /** Actions rendered in the section header (e.g. a create-form button). */
77
+ headerActions?: Action[];
78
+ /** Filters rendered above the rows; each adds `key=value` to the source query and to action calls as the filter context. */
79
+ filters?: TableFilter[];
80
+ /** Render a text search input filtering the loaded rows client-side. */
81
+ search?: boolean;
82
+ }
83
+ | {
84
+ type: 'form';
85
+ title: L10n;
86
+ fields: FieldSpec[];
87
+ submit: RouteRef;
88
+ confirm?: L10n /** Render as a modal opened by a button labeled with the title. */;
89
+ modal?: boolean;
43
90
  }
44
- | { type: 'form'; title: L10n; fields: FieldSpec[]; submit: RouteRef; confirm?: L10n }
45
91
  | { type: 'actions'; actions: Action[] }
46
92
  | { type: 'markdown'; body: L10n }
47
93
  | { type: 'frame'; route: string; height?: number };
@@ -70,6 +116,38 @@ export const ActionSchema = z.object({
70
116
  route: RouteRefSchema,
71
117
  confirm: L10nSchema.optional(),
72
118
  destructive: z.boolean().optional(),
119
+ kind: z.enum(['switch', 'form']).optional(),
120
+ checkedKey: z.string().min(1).optional(),
121
+ fields: z.array(FieldSpecSchema).optional(),
122
+ prefill: z.record(z.string(), z.string()).optional(),
123
+ formActions: z
124
+ .array(
125
+ z.object({
126
+ id: z.string().min(1),
127
+ label: L10nSchema,
128
+ route: RouteRefSchema,
129
+ confirm: L10nSchema.optional(),
130
+ destructive: z.boolean().optional(),
131
+ }),
132
+ )
133
+ .optional(),
134
+ batchRoute: RouteRefSchema.optional(),
135
+ });
136
+
137
+ export const TableFilterSchema = z.object({
138
+ key: z.string().min(1),
139
+ label: L10nSchema,
140
+ options: z
141
+ .array(z.object({ value: z.string(), label: z.string() }))
142
+ .min(1)
143
+ .optional(),
144
+ optionsFrom: z
145
+ .object({
146
+ route: z.string().min(1),
147
+ valueKey: z.string().min(1),
148
+ labelKey: z.string().min(1).optional(),
149
+ })
150
+ .optional(),
73
151
  });
74
152
 
75
153
  const baseSections = {
@@ -93,6 +171,11 @@ const baseSections = {
93
171
  columns: z.array(ColumnSchema).min(1),
94
172
  rowActions: z.array(ActionSchema).optional(),
95
173
  pageSize: z.number().int().positive().optional(),
174
+ selectable: z.boolean().optional(),
175
+ selectionActions: z.array(ActionSchema).optional(),
176
+ headerActions: z.array(ActionSchema).optional(),
177
+ filters: z.array(TableFilterSchema).optional(),
178
+ search: z.boolean().optional(),
96
179
  }),
97
180
  form: z.object({
98
181
  type: z.literal('form'),
@@ -100,6 +183,7 @@ const baseSections = {
100
183
  fields: z.array(FieldSpecSchema).min(1),
101
184
  submit: RouteRefSchema,
102
185
  confirm: L10nSchema.optional(),
186
+ modal: z.boolean().optional(),
103
187
  }),
104
188
  actions: z.object({ type: z.literal('actions'), actions: z.array(ActionSchema).min(1) }),
105
189
  markdown: z.object({ type: z.literal('markdown'), body: L10nSchema }),
@@ -21,10 +21,10 @@ export function createHostClient(channel: HostChannel, getMeta: () => CallMeta):
21
21
  if (!spec) {
22
22
  throw new Error(`method '${entry.method}' is not in the protocol map`);
23
23
  }
24
- const parsedParams = spec.params.parse({
25
- ...(params as Record<string, unknown>),
24
+ const parsedParams = {
25
+ ...(spec.params.parse(params) as Record<string, unknown>),
26
26
  _meta: getMeta(),
27
- });
27
+ };
28
28
  const raw = await channel.request(entry.method, parsedParams, options?.signal);
29
29
  return spec.result ? spec.result.parse(raw) : raw;
30
30
  };
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export {
20
20
  type AddonTriggerField,
21
21
  type AddonTriggers,
22
22
  type AddonTriggerTarget,
23
+ type AddonTriggerWorkspace,
23
24
  type AddonUsage,
24
25
  type AddonWorkers,
25
26
  createAddonContext,
@@ -122,7 +122,11 @@ export async function startAddonProcess(options: StartAddonProcessOptions): Prom
122
122
  function replyError(id: string | number | null, error: unknown): void {
123
123
  const data = isAddonError(error)
124
124
  ? error.toData()
125
- : { reason: 'internal' as const, retryable: false };
125
+ : {
126
+ reason: 'internal' as const,
127
+ retryable: false,
128
+ detail: error instanceof Error ? error.message : String(error),
129
+ };
126
130
  if (!isAddonError(error)) {
127
131
  wiring.stderr.write(
128
132
  `addon request failed: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`,
@@ -85,6 +85,7 @@ export const protocolMap = {
85
85
  label: str.optional(),
86
86
  config: z.record(z.string(), z.unknown()),
87
87
  target: z.unknown().optional(),
88
+ instructions: str.optional(),
88
89
  })
89
90
  .extend({ _meta: CallMetaSchema }),
90
91
  empty,
@@ -4,6 +4,26 @@ import { TriggerFireOutcomeSchema } from './shared.ts';
4
4
 
5
5
  const str = z.string().min(1);
6
6
 
7
+ const TriggerWorkspaceSchema = z.discriminatedUnion('kind', [
8
+ z.object({ kind: z.literal('inherit') }),
9
+ z.object({ kind: z.literal('sandbox') }),
10
+ z.object({ kind: z.literal('folder'), path: str, hostId: str.optional() }),
11
+ z.object({ kind: z.literal('source'), sourceId: str, subpath: str.optional() }),
12
+ z.object({
13
+ kind: z.literal('worktree'),
14
+ sourceId: str,
15
+ worktreeId: str,
16
+ subpath: str.optional(),
17
+ }),
18
+ ]);
19
+
20
+ const TriggerTargetSchema = z.object({
21
+ threadId: str,
22
+ agentId: str,
23
+ modeId: str.optional(),
24
+ workspace: TriggerWorkspaceSchema.optional(),
25
+ });
26
+
7
27
  /** Read/action methods over org-scoped thread, run, usage and skill state (§6.4). */
8
28
  export const orgServiceMethods = {
9
29
  'runs.list': addonMethod(
@@ -117,11 +137,7 @@ export const orgServiceMethods = {
117
137
  kind: str,
118
138
  label: str,
119
139
  config: z.record(z.string(), z.unknown()).default({}),
120
- target: z.object({
121
- threadId: str,
122
- agentId: str,
123
- modeId: str.optional(),
124
- }),
140
+ target: TriggerTargetSchema,
125
141
  instructions: str.optional(),
126
142
  }),
127
143
  z.object({ instanceId: str }),
@@ -132,13 +148,7 @@ export const orgServiceMethods = {
132
148
  instanceId: str,
133
149
  label: str.optional(),
134
150
  config: z.record(z.string(), z.unknown()).optional(),
135
- target: z
136
- .object({
137
- threadId: str,
138
- agentId: str,
139
- modeId: str.optional(),
140
- })
141
- .optional(),
151
+ target: TriggerTargetSchema.optional(),
142
152
  instructions: str.optional(),
143
153
  enabled: z.boolean().optional(),
144
154
  }),
@@ -137,6 +137,8 @@ export const CloudRemoteEntrySchema = z.object({
137
137
  modifiedAt: z.string().min(1).optional(),
138
138
  mimeType: z.string().min(1).optional(),
139
139
  export: CloudRemoteExportSchema.optional(),
140
+ /** HTTPS clone URL; required on entries of `mount: 'git'` source kinds. */
141
+ url: z.string().min(1).optional(),
140
142
  });
141
143
  export type CloudRemoteEntryWire = z.infer<typeof CloudRemoteEntrySchema>;
142
144
  export type CloudRemoteExportWire = z.infer<typeof CloudRemoteExportSchema>;