@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.
- package/README.md +17 -3
- package/dist/addon-context-factory.d.ts +1 -1
- package/dist/addon-context.d.ts +19 -0
- package/dist/define-addon.d.ts +1 -1
- package/dist/define-addon.js +2 -2
- package/dist/families/field-spec.d.ts +9 -1
- package/dist/families/field-spec.js +4 -0
- package/dist/families/source-kind.d.ts +11 -0
- package/dist/families/source-kind.js +1 -0
- package/dist/families/view.d.ts +320 -1
- package/dist/families/view.js +35 -0
- package/dist/families/viewer.d.ts +13 -1
- package/dist/families/viewer.js +3 -0
- package/dist/host-client.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/process-entry.js +5 -1
- package/dist/protocol/map.d.ts +39 -0
- package/dist/protocol/map.js +1 -0
- package/dist/protocol/org-service-methods.d.ts +36 -0
- package/dist/protocol/org-service-methods.js +20 -12
- package/dist/protocol/shared.d.ts +3 -0
- package/dist/protocol/shared.js +2 -0
- package/dist/protocol/source-methods.d.ts +2 -0
- package/package.json +1 -1
- package/src/addon-context-factory.ts +1 -0
- package/src/addon-context.ts +8 -0
- package/src/define-addon.ts +3 -3
- package/src/families/field-spec.ts +11 -0
- package/src/families/source-kind.ts +8 -0
- package/src/families/view.ts +85 -1
- package/src/families/viewer.ts +14 -1
- package/src/host-client.ts +3 -3
- package/src/index.ts +1 -0
- package/src/process-entry.ts +5 -1
- package/src/protocol/map.ts +1 -0
- package/src/protocol/org-service-methods.ts +22 -12
- package/src/protocol/shared.ts +2 -0
package/src/families/viewer.ts
CHANGED
|
@@ -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 "
|
|
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 = {
|
package/src/host-client.ts
CHANGED
|
@@ -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 =
|
|
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
package/src/process-entry.ts
CHANGED
|
@@ -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
|
-
: {
|
|
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`,
|
package/src/protocol/map.ts
CHANGED
|
@@ -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:
|
|
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:
|
|
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
|
}),
|
package/src/protocol/shared.ts
CHANGED
|
@@ -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>;
|