@harnesys/sdk 1.1.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.
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { AddonIconRefSchema } from '../manifest/branding.ts';
2
3
  import type { L10n } from '../manifest/l10n.ts';
3
4
  import { L10nSchema } from '../manifest/l10n.ts';
4
5
 
@@ -12,8 +13,18 @@ export interface ViewerDescriptor {
12
13
  /** Add-on route (GET) that serves the editor/preview HTML document. */
13
14
  route: string;
14
15
  mode: 'view' | 'edit';
15
- /** Host offers "New <title> file" in the sources tree when true. */
16
+ /** Host offers a "create file" entry in the sources tree when true. */
16
17
  create?: boolean;
18
+ /**
19
+ * Full label of that entry, e.g. `{'en': 'New Draw.io'}`. The host renders it
20
+ * verbatim; without it the entry falls back to `New <title>`.
21
+ */
22
+ createLabel?: L10n;
23
+ /**
24
+ * Icon shown for the extensions above in the sources tree and its menus:
25
+ * a lucide icon name or an SVG shipped with the package (`assets/*.svg`).
26
+ */
27
+ icon?: string;
17
28
  }
18
29
 
19
30
  export const ViewerExtensionSchema = z
@@ -29,6 +40,8 @@ export const ViewerDescriptorSchema = z.object({
29
40
  .regex(/^\/[A-Za-z0-9/_:.-]*$/, 'route must start with / and use :param segments'),
30
41
  mode: z.enum(['view', 'edit']),
31
42
  create: z.boolean().optional(),
43
+ createLabel: L10nSchema.optional(),
44
+ icon: AddonIconRefSchema.optional(),
32
45
  });
33
46
 
34
47
  export const viewerFamily = {
@@ -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>;