@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,106 @@
1
+ import type { ResolvedAddonDefinition } from '../define-addon.ts';
2
+ import { defineAddon } from '../define-addon.ts';
3
+ import type { AddonManifest } from '../manifest/manifest.ts';
4
+
5
+ export function validManifest(): AddonManifest {
6
+ return {
7
+ id: 'harnesys.demo',
8
+ version: '1.0.0',
9
+ platform: 1,
10
+ title: 'Demo',
11
+ description: 'Demo addon',
12
+ runtime: { entry: './dist/index.js', profile: 'restricted' },
13
+ activation: 'lazy',
14
+ permissions: [
15
+ { id: 'http.fetch', scope: { hosts: ['api.example.com'] }, reason: 'Calls the example API' },
16
+ ],
17
+ connections: [
18
+ {
19
+ id: 'example',
20
+ label: 'Example connection',
21
+ accountKinds: ['example-account'],
22
+ cardinality: 'many',
23
+ },
24
+ ],
25
+ contributions: [
26
+ {
27
+ id: 'pack',
28
+ family: 'tool-pack',
29
+ descriptor: {
30
+ name: 'example',
31
+ title: 'Example tools',
32
+ description: 'Tools for the demo',
33
+ connection: 'example',
34
+ tools: [
35
+ {
36
+ name: 'example.ping',
37
+ description: 'Ping',
38
+ inputSchema: { type: 'object' },
39
+ effect: 'read',
40
+ },
41
+ ],
42
+ },
43
+ },
44
+ {
45
+ id: 'hook',
46
+ family: 'hook',
47
+ descriptor: { id: 'onThread', on: { event: 'thread.*' } },
48
+ },
49
+ ],
50
+ };
51
+ }
52
+
53
+ export function toolPackManifest(tools: Array<Record<string, unknown>>): AddonManifest {
54
+ return {
55
+ ...validManifest(),
56
+ contributions: [
57
+ {
58
+ id: 'pack',
59
+ family: 'tool-pack',
60
+ descriptor: {
61
+ name: 'example',
62
+ title: 'Example tools',
63
+ description: 'Tools for the demo',
64
+ tools,
65
+ },
66
+ },
67
+ ],
68
+ };
69
+ }
70
+
71
+ export function demoDefinition(): ResolvedAddonDefinition {
72
+ return defineAddon({
73
+ tools: {
74
+ 'example.ping': (input, ctx) => ({ pong: true, echo: input, org: ctx.meta.correlationId }),
75
+ },
76
+ routes: {
77
+ items: async () => ({ status: 200, body: { rows: [] } }),
78
+ },
79
+ triggers: {
80
+ 'telegram.feed': {
81
+ start: async () => undefined,
82
+ stop: async () => undefined,
83
+ },
84
+ },
85
+ jobs: {
86
+ sync: async (_params, ctx) => {
87
+ await ctx.log.info('job ran');
88
+ },
89
+ },
90
+ hooks: {
91
+ onThread: async () => undefined,
92
+ },
93
+ sources: {
94
+ example: {
95
+ list: async () => ({ entries: [{ id: 'file-1', name: 'notes.txt', kind: 'file' }] }),
96
+ stat: async (params) => ({
97
+ entry: { id: params.fileId, name: 'notes.txt', kind: 'file' },
98
+ }),
99
+ download: async () => ({ data: '', eof: true }),
100
+ },
101
+ },
102
+ transport: {
103
+ typing: async () => undefined,
104
+ },
105
+ });
106
+ }
@@ -0,0 +1,12 @@
1
+ export type { FakeDb } from './fake-db.ts';
2
+ export { createFakeDb, guardSql, SqlAuthorizerError } from './fake-db.ts';
3
+ export type {
4
+ FakeAccount,
5
+ FakeGrant,
6
+ FakeHost,
7
+ FakeHostOptions,
8
+ FakeHttpHandler,
9
+ FakeHttpRequest,
10
+ FakeHttpResponse,
11
+ } from './fake-host.ts';
12
+ export { createFakeHost } from './fake-host.ts';