@harnesys/sdk 0.0.0-stage → 1.1.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/LICENSE +21 -0
- package/README.md +80 -2
- package/dist/addon-context-factory.d.ts +6 -0
- package/dist/addon-context-factory.js +160 -0
- package/dist/addon-context.d.ts +346 -0
- package/dist/addon-context.js +0 -0
- package/dist/define-addon.d.ts +57 -0
- package/dist/define-addon.js +53 -0
- package/dist/families/config.d.ts +14 -0
- package/dist/families/config.js +16 -0
- package/dist/families/content.d.ts +28 -0
- package/dist/families/content.js +19 -0
- package/dist/families/field-spec.d.ts +100 -0
- package/dist/families/field-spec.js +85 -0
- package/dist/families/hook.d.ts +37 -0
- package/dist/families/hook.js +25 -0
- package/dist/families/job.d.ts +45 -0
- package/dist/families/job.js +26 -0
- package/dist/families/json-schema-value.d.ts +12 -0
- package/dist/families/json-schema-value.js +243 -0
- package/dist/families/json-schema.d.ts +36 -0
- package/dist/families/json-schema.js +101 -0
- package/dist/families/lsp.d.ts +18 -0
- package/dist/families/lsp.js +18 -0
- package/dist/families/mcp.d.ts +18 -0
- package/dist/families/mcp.js +18 -0
- package/dist/families/registry.d.ts +9 -0
- package/dist/families/registry.js +34 -0
- package/dist/families/route.d.ts +38 -0
- package/dist/families/route.js +37 -0
- package/dist/families/source-kind.d.ts +24 -0
- package/dist/families/source-kind.js +21 -0
- package/dist/families/tool-pack.d.ts +68 -0
- package/dist/families/tool-pack.js +57 -0
- package/dist/families/transport.d.ts +52 -0
- package/dist/families/transport.js +29 -0
- package/dist/families/trigger.d.ts +97 -0
- package/dist/families/trigger.js +46 -0
- package/dist/families/view.d.ts +255 -0
- package/dist/families/view.js +87 -0
- package/dist/families/viewer.d.ts +31 -0
- package/dist/families/viewer.js +26 -0
- package/dist/families/worker.d.ts +23 -0
- package/dist/families/worker.js +19 -0
- package/dist/host-client.d.ts +11 -0
- package/dist/host-client.js +30 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +36 -0
- package/dist/manifest/branding.d.ts +14 -0
- package/dist/manifest/branding.js +18 -0
- package/dist/manifest/connections.d.ts +21 -0
- package/dist/manifest/connections.js +10 -0
- package/dist/manifest/json-schema.d.ts +2 -0
- package/dist/manifest/json-schema.js +13 -0
- package/dist/manifest/l10n.d.ts +9 -0
- package/dist/manifest/l10n.js +28 -0
- package/dist/manifest/manifest.d.ts +112 -0
- package/dist/manifest/manifest.js +45 -0
- package/dist/manifest/validate.d.ts +14 -0
- package/dist/manifest/validate.js +144 -0
- package/dist/permissions/permissions.d.ts +31 -0
- package/dist/permissions/permissions.js +53 -0
- package/dist/process-entry.d.ts +26 -0
- package/dist/process-entry.js +146 -0
- package/dist/protocol/envelope.d.ts +115 -0
- package/dist/protocol/envelope.js +72 -0
- package/dist/protocol/error.d.ts +67 -0
- package/dist/protocol/error.js +61 -0
- package/dist/protocol/handshake.d.ts +55 -0
- package/dist/protocol/handshake.js +26 -0
- package/dist/protocol/map.d.ts +1090 -0
- package/dist/protocol/map.js +127 -0
- package/dist/protocol/meta.d.ts +31 -0
- package/dist/protocol/meta.js +14 -0
- package/dist/protocol/method-spec.d.ts +13 -0
- package/dist/protocol/method-spec.js +9 -0
- package/dist/protocol/org-service-methods.d.ts +135 -0
- package/dist/protocol/org-service-methods.js +106 -0
- package/dist/protocol/shared.d.ts +389 -0
- package/dist/protocol/shared.js +231 -0
- package/dist/protocol/source-methods.d.ts +218 -0
- package/dist/protocol/source-methods.js +18 -0
- package/dist/protocol/thread-service-methods.d.ts +50 -0
- package/dist/protocol/thread-service-methods.js +32 -0
- package/dist/runtime.d.ts +25 -0
- package/dist/runtime.js +229 -0
- package/dist/testing/fake-db.d.ts +15 -0
- package/dist/testing/fake-db.js +120 -0
- package/dist/testing/fake-files.d.ts +9 -0
- package/dist/testing/fake-files.js +87 -0
- package/dist/testing/fake-host.d.ts +115 -0
- package/dist/testing/fake-host.js +217 -0
- package/dist/testing/fake-services.d.ts +63 -0
- package/dist/testing/fake-services.js +277 -0
- package/dist/testing/fixtures.d.ts +5 -0
- package/dist/testing/fixtures.js +101 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +2 -0
- package/package.json +66 -4
- package/src/addon-context-factory.ts +236 -0
- package/src/addon-context.ts +313 -0
- package/src/define-addon.ts +178 -0
- package/src/families/config.ts +24 -0
- package/src/families/content.ts +35 -0
- package/src/families/field-spec.ts +175 -0
- package/src/families/hook.ts +34 -0
- package/src/families/job.ts +41 -0
- package/src/families/json-schema-value.ts +322 -0
- package/src/families/json-schema.ts +167 -0
- package/src/families/lsp.ts +28 -0
- package/src/families/mcp.ts +28 -0
- package/src/families/registry.ts +44 -0
- package/src/families/route.ts +52 -0
- package/src/families/source-kind.ts +34 -0
- package/src/families/tool-pack.ts +92 -0
- package/src/families/transport.ts +52 -0
- package/src/families/trigger.ts +92 -0
- package/src/families/view.ts +144 -0
- package/src/families/viewer.ts +43 -0
- package/src/families/worker.ts +30 -0
- package/src/host-client.ts +52 -0
- package/src/index.ts +345 -0
- package/src/manifest/branding.ts +24 -0
- package/src/manifest/connections.ts +21 -0
- package/src/manifest/json-schema.ts +24 -0
- package/src/manifest/l10n.ts +39 -0
- package/src/manifest/manifest.ts +94 -0
- package/src/manifest/validate.ts +200 -0
- package/src/permissions/permissions.ts +79 -0
- package/src/process-entry.ts +205 -0
- package/src/protocol/envelope.ts +126 -0
- package/src/protocol/error.ts +81 -0
- package/src/protocol/handshake.ts +43 -0
- package/src/protocol/map.ts +339 -0
- package/src/protocol/meta.ts +26 -0
- package/src/protocol/method-spec.ts +40 -0
- package/src/protocol/org-service-methods.ts +148 -0
- package/src/protocol/shared.ts +345 -0
- package/src/protocol/source-methods.ts +61 -0
- package/src/protocol/thread-service-methods.ts +50 -0
- package/src/runtime.ts +332 -0
- package/src/testing/fake-db.ts +140 -0
- package/src/testing/fake-files.ts +114 -0
- package/src/testing/fake-host.ts +350 -0
- package/src/testing/fake-services.ts +345 -0
- package/src/testing/fixtures.ts +106 -0
- package/src/testing/index.ts +12 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const AddonErrorReasonSchema = z.enum([
|
|
3
|
+
'invalid_params',
|
|
4
|
+
'invalid_response',
|
|
5
|
+
'permission_denied',
|
|
6
|
+
'not_found',
|
|
7
|
+
'conflict',
|
|
8
|
+
'quota_exceeded',
|
|
9
|
+
'rate_limited',
|
|
10
|
+
'timeout',
|
|
11
|
+
'cancelled',
|
|
12
|
+
'unavailable',
|
|
13
|
+
'unsupported',
|
|
14
|
+
'account_failed',
|
|
15
|
+
'incompatible_handlers',
|
|
16
|
+
'migration_failed',
|
|
17
|
+
'permission_revoked',
|
|
18
|
+
'internal',
|
|
19
|
+
]);
|
|
20
|
+
export const AddonErrorDataSchema = z.object({
|
|
21
|
+
reason: AddonErrorReasonSchema,
|
|
22
|
+
retryable: z.boolean(),
|
|
23
|
+
detail: z.string().optional(),
|
|
24
|
+
accountCode: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
export class AddonError extends Error {
|
|
27
|
+
reason;
|
|
28
|
+
retryable;
|
|
29
|
+
detail;
|
|
30
|
+
accountCode;
|
|
31
|
+
constructor(reason, options) {
|
|
32
|
+
super(options?.detail ?? reason);
|
|
33
|
+
this.name = 'AddonError';
|
|
34
|
+
this.reason = reason;
|
|
35
|
+
this.retryable = options?.retryable ?? false;
|
|
36
|
+
this.detail = options?.detail;
|
|
37
|
+
this.accountCode = options?.accountCode;
|
|
38
|
+
}
|
|
39
|
+
toData() {
|
|
40
|
+
return {
|
|
41
|
+
reason: this.reason,
|
|
42
|
+
retryable: this.retryable,
|
|
43
|
+
detail: this.detail,
|
|
44
|
+
accountCode: this.accountCode,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Copy-safe detection: the addon dist bundles its own copy of this module, so
|
|
50
|
+
* in-process hosts see errors whose class identity differs from the host's
|
|
51
|
+
* `AddonError`. Detect structurally instead of by `instanceof` alone.
|
|
52
|
+
*/
|
|
53
|
+
export function isAddonError(error) {
|
|
54
|
+
if (error instanceof AddonError) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return (error instanceof Error &&
|
|
58
|
+
error.name === 'AddonError' &&
|
|
59
|
+
'reason' in error &&
|
|
60
|
+
typeof error.toData === 'function');
|
|
61
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export interface InitializeParams {
|
|
3
|
+
platform: number;
|
|
4
|
+
host: {
|
|
5
|
+
version: string;
|
|
6
|
+
features: string[];
|
|
7
|
+
};
|
|
8
|
+
instance: {
|
|
9
|
+
orgId: string;
|
|
10
|
+
generation: number;
|
|
11
|
+
dataDir: string;
|
|
12
|
+
locale: string;
|
|
13
|
+
};
|
|
14
|
+
permissions: Array<{
|
|
15
|
+
id: string;
|
|
16
|
+
scope?: Record<string, unknown>;
|
|
17
|
+
}>;
|
|
18
|
+
experimental: string[];
|
|
19
|
+
deprecations: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface InitializeResult {
|
|
22
|
+
addon: {
|
|
23
|
+
id: string;
|
|
24
|
+
version: string;
|
|
25
|
+
};
|
|
26
|
+
handlers: string[];
|
|
27
|
+
deactivateTimeoutMs?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare const InitializeParamsSchema: z.ZodObject<{
|
|
30
|
+
platform: z.ZodNumber;
|
|
31
|
+
host: z.ZodObject<{
|
|
32
|
+
version: z.ZodString;
|
|
33
|
+
features: z.ZodArray<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
instance: z.ZodObject<{
|
|
36
|
+
orgId: z.ZodString;
|
|
37
|
+
generation: z.ZodNumber;
|
|
38
|
+
dataDir: z.ZodString;
|
|
39
|
+
locale: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
permissions: z.ZodArray<z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
scope: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
experimental: z.ZodArray<z.ZodString>;
|
|
46
|
+
deprecations: z.ZodArray<z.ZodString>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export declare const InitializeResultSchema: z.ZodObject<{
|
|
49
|
+
addon: z.ZodObject<{
|
|
50
|
+
id: z.ZodString;
|
|
51
|
+
version: z.ZodString;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
handlers: z.ZodArray<z.ZodString>;
|
|
54
|
+
deactivateTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EffectivePermissionSchema } from "../permissions/permissions.js";
|
|
3
|
+
export const InitializeParamsSchema = z.object({
|
|
4
|
+
platform: z.number().int().positive(),
|
|
5
|
+
host: z.object({
|
|
6
|
+
version: z.string().min(1),
|
|
7
|
+
features: z.array(z.string()),
|
|
8
|
+
}),
|
|
9
|
+
instance: z.object({
|
|
10
|
+
orgId: z.string().min(1),
|
|
11
|
+
generation: z.number().int().nonnegative(),
|
|
12
|
+
dataDir: z.string().min(1),
|
|
13
|
+
locale: z.string().min(1),
|
|
14
|
+
}),
|
|
15
|
+
permissions: z.array(EffectivePermissionSchema),
|
|
16
|
+
experimental: z.array(z.string()),
|
|
17
|
+
deprecations: z.array(z.string()),
|
|
18
|
+
});
|
|
19
|
+
export const InitializeResultSchema = z.object({
|
|
20
|
+
addon: z.object({
|
|
21
|
+
id: z.string().min(1),
|
|
22
|
+
version: z.string().min(1),
|
|
23
|
+
}),
|
|
24
|
+
handlers: z.array(z.string()),
|
|
25
|
+
deactivateTimeoutMs: z.number().int().positive().optional(),
|
|
26
|
+
});
|