@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.
Files changed (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -2
  3. package/dist/addon-context-factory.d.ts +6 -0
  4. package/dist/addon-context-factory.js +160 -0
  5. package/dist/addon-context.d.ts +346 -0
  6. package/dist/addon-context.js +0 -0
  7. package/dist/define-addon.d.ts +57 -0
  8. package/dist/define-addon.js +53 -0
  9. package/dist/families/config.d.ts +14 -0
  10. package/dist/families/config.js +16 -0
  11. package/dist/families/content.d.ts +28 -0
  12. package/dist/families/content.js +19 -0
  13. package/dist/families/field-spec.d.ts +100 -0
  14. package/dist/families/field-spec.js +85 -0
  15. package/dist/families/hook.d.ts +37 -0
  16. package/dist/families/hook.js +25 -0
  17. package/dist/families/job.d.ts +45 -0
  18. package/dist/families/job.js +26 -0
  19. package/dist/families/json-schema-value.d.ts +12 -0
  20. package/dist/families/json-schema-value.js +243 -0
  21. package/dist/families/json-schema.d.ts +36 -0
  22. package/dist/families/json-schema.js +101 -0
  23. package/dist/families/lsp.d.ts +18 -0
  24. package/dist/families/lsp.js +18 -0
  25. package/dist/families/mcp.d.ts +18 -0
  26. package/dist/families/mcp.js +18 -0
  27. package/dist/families/registry.d.ts +9 -0
  28. package/dist/families/registry.js +34 -0
  29. package/dist/families/route.d.ts +38 -0
  30. package/dist/families/route.js +37 -0
  31. package/dist/families/source-kind.d.ts +24 -0
  32. package/dist/families/source-kind.js +21 -0
  33. package/dist/families/tool-pack.d.ts +68 -0
  34. package/dist/families/tool-pack.js +57 -0
  35. package/dist/families/transport.d.ts +52 -0
  36. package/dist/families/transport.js +29 -0
  37. package/dist/families/trigger.d.ts +97 -0
  38. package/dist/families/trigger.js +46 -0
  39. package/dist/families/view.d.ts +255 -0
  40. package/dist/families/view.js +87 -0
  41. package/dist/families/viewer.d.ts +31 -0
  42. package/dist/families/viewer.js +26 -0
  43. package/dist/families/worker.d.ts +23 -0
  44. package/dist/families/worker.js +19 -0
  45. package/dist/host-client.d.ts +11 -0
  46. package/dist/host-client.js +30 -0
  47. package/dist/index.d.ts +36 -0
  48. package/dist/index.js +36 -0
  49. package/dist/manifest/branding.d.ts +14 -0
  50. package/dist/manifest/branding.js +18 -0
  51. package/dist/manifest/connections.d.ts +21 -0
  52. package/dist/manifest/connections.js +10 -0
  53. package/dist/manifest/json-schema.d.ts +2 -0
  54. package/dist/manifest/json-schema.js +13 -0
  55. package/dist/manifest/l10n.d.ts +9 -0
  56. package/dist/manifest/l10n.js +28 -0
  57. package/dist/manifest/manifest.d.ts +112 -0
  58. package/dist/manifest/manifest.js +45 -0
  59. package/dist/manifest/validate.d.ts +14 -0
  60. package/dist/manifest/validate.js +144 -0
  61. package/dist/permissions/permissions.d.ts +31 -0
  62. package/dist/permissions/permissions.js +53 -0
  63. package/dist/process-entry.d.ts +26 -0
  64. package/dist/process-entry.js +146 -0
  65. package/dist/protocol/envelope.d.ts +115 -0
  66. package/dist/protocol/envelope.js +72 -0
  67. package/dist/protocol/error.d.ts +67 -0
  68. package/dist/protocol/error.js +61 -0
  69. package/dist/protocol/handshake.d.ts +55 -0
  70. package/dist/protocol/handshake.js +26 -0
  71. package/dist/protocol/map.d.ts +1090 -0
  72. package/dist/protocol/map.js +127 -0
  73. package/dist/protocol/meta.d.ts +31 -0
  74. package/dist/protocol/meta.js +14 -0
  75. package/dist/protocol/method-spec.d.ts +13 -0
  76. package/dist/protocol/method-spec.js +9 -0
  77. package/dist/protocol/org-service-methods.d.ts +135 -0
  78. package/dist/protocol/org-service-methods.js +106 -0
  79. package/dist/protocol/shared.d.ts +389 -0
  80. package/dist/protocol/shared.js +231 -0
  81. package/dist/protocol/source-methods.d.ts +218 -0
  82. package/dist/protocol/source-methods.js +18 -0
  83. package/dist/protocol/thread-service-methods.d.ts +50 -0
  84. package/dist/protocol/thread-service-methods.js +32 -0
  85. package/dist/runtime.d.ts +25 -0
  86. package/dist/runtime.js +229 -0
  87. package/dist/testing/fake-db.d.ts +15 -0
  88. package/dist/testing/fake-db.js +120 -0
  89. package/dist/testing/fake-files.d.ts +9 -0
  90. package/dist/testing/fake-files.js +87 -0
  91. package/dist/testing/fake-host.d.ts +115 -0
  92. package/dist/testing/fake-host.js +217 -0
  93. package/dist/testing/fake-services.d.ts +63 -0
  94. package/dist/testing/fake-services.js +277 -0
  95. package/dist/testing/fixtures.d.ts +5 -0
  96. package/dist/testing/fixtures.js +101 -0
  97. package/dist/testing/index.d.ts +4 -0
  98. package/dist/testing/index.js +2 -0
  99. package/package.json +66 -4
  100. package/src/addon-context-factory.ts +236 -0
  101. package/src/addon-context.ts +313 -0
  102. package/src/define-addon.ts +178 -0
  103. package/src/families/config.ts +24 -0
  104. package/src/families/content.ts +35 -0
  105. package/src/families/field-spec.ts +175 -0
  106. package/src/families/hook.ts +34 -0
  107. package/src/families/job.ts +41 -0
  108. package/src/families/json-schema-value.ts +322 -0
  109. package/src/families/json-schema.ts +167 -0
  110. package/src/families/lsp.ts +28 -0
  111. package/src/families/mcp.ts +28 -0
  112. package/src/families/registry.ts +44 -0
  113. package/src/families/route.ts +52 -0
  114. package/src/families/source-kind.ts +34 -0
  115. package/src/families/tool-pack.ts +92 -0
  116. package/src/families/transport.ts +52 -0
  117. package/src/families/trigger.ts +92 -0
  118. package/src/families/view.ts +144 -0
  119. package/src/families/viewer.ts +43 -0
  120. package/src/families/worker.ts +30 -0
  121. package/src/host-client.ts +52 -0
  122. package/src/index.ts +345 -0
  123. package/src/manifest/branding.ts +24 -0
  124. package/src/manifest/connections.ts +21 -0
  125. package/src/manifest/json-schema.ts +24 -0
  126. package/src/manifest/l10n.ts +39 -0
  127. package/src/manifest/manifest.ts +94 -0
  128. package/src/manifest/validate.ts +200 -0
  129. package/src/permissions/permissions.ts +79 -0
  130. package/src/process-entry.ts +205 -0
  131. package/src/protocol/envelope.ts +126 -0
  132. package/src/protocol/error.ts +81 -0
  133. package/src/protocol/handshake.ts +43 -0
  134. package/src/protocol/map.ts +339 -0
  135. package/src/protocol/meta.ts +26 -0
  136. package/src/protocol/method-spec.ts +40 -0
  137. package/src/protocol/org-service-methods.ts +148 -0
  138. package/src/protocol/shared.ts +345 -0
  139. package/src/protocol/source-methods.ts +61 -0
  140. package/src/protocol/thread-service-methods.ts +50 -0
  141. package/src/runtime.ts +332 -0
  142. package/src/testing/fake-db.ts +140 -0
  143. package/src/testing/fake-files.ts +114 -0
  144. package/src/testing/fake-host.ts +350 -0
  145. package/src/testing/fake-services.ts +345 -0
  146. package/src/testing/fixtures.ts +106 -0
  147. 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
+ });