@openwaggle/extension-sdk 0.0.0-bootstrap.0 → 0.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 (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -0
  4. package/dist/agent-loop.d.ts +128 -0
  5. package/dist/agent-loop.js +47 -0
  6. package/dist/broker-validation.d.ts +17 -0
  7. package/dist/broker-validation.js +99 -0
  8. package/dist/broker.d.ts +193 -0
  9. package/dist/broker.js +81 -0
  10. package/dist/constants.d.ts +183 -0
  11. package/dist/constants.js +245 -0
  12. package/dist/context.d.ts +66 -0
  13. package/dist/context.js +49 -0
  14. package/dist/contribution-types.d.ts +21 -0
  15. package/dist/contribution-types.js +1 -0
  16. package/dist/core-types.d.ts +58 -0
  17. package/dist/core-types.js +1 -0
  18. package/dist/docs-validation.d.ts +3 -0
  19. package/dist/docs-validation.js +93 -0
  20. package/dist/docs.d.ts +231 -0
  21. package/dist/docs.js +85 -0
  22. package/dist/index.d.ts +15 -0
  23. package/dist/index.js +10 -0
  24. package/dist/internal-validation.d.ts +4 -0
  25. package/dist/internal-validation.js +24 -0
  26. package/dist/json.d.ts +9 -0
  27. package/dist/json.js +3 -0
  28. package/dist/manifest-contributions.d.ts +380 -0
  29. package/dist/manifest-contributions.js +75 -0
  30. package/dist/manifest-primitives.d.ts +20 -0
  31. package/dist/manifest-primitives.js +118 -0
  32. package/dist/manifest.d.ts +303 -0
  33. package/dist/manifest.js +89 -0
  34. package/dist/openwaggle-sdk.d.ts +2 -0
  35. package/dist/openwaggle-sdk.js +127 -0
  36. package/dist/openwaggle-types.d.ts +111 -0
  37. package/dist/openwaggle-types.js +1 -0
  38. package/dist/openwaggle-validation.d.ts +12 -0
  39. package/dist/openwaggle-validation.js +135 -0
  40. package/dist/registry-types.d.ts +34 -0
  41. package/dist/registry-types.js +1 -0
  42. package/dist/runtime-sdk.d.ts +2 -0
  43. package/dist/runtime-sdk.js +19 -0
  44. package/dist/runtime-types.d.ts +19 -0
  45. package/dist/runtime-types.js +1 -0
  46. package/dist/runtime.d.ts +22 -0
  47. package/dist/runtime.js +22 -0
  48. package/dist/schema.d.ts +13 -0
  49. package/dist/schema.js +25 -0
  50. package/dist/sdk-types.d.ts +92 -0
  51. package/dist/sdk-types.js +1 -0
  52. package/dist/storage-sdk.d.ts +2 -0
  53. package/dist/storage-sdk.js +51 -0
  54. package/dist/storage-types.d.ts +40 -0
  55. package/dist/storage-types.js +1 -0
  56. package/dist/theme-data.d.ts +126 -0
  57. package/dist/theme-data.js +144 -0
  58. package/dist/theme-types.d.ts +61 -0
  59. package/dist/theme-types.js +1 -0
  60. package/dist/theme.d.ts +6 -0
  61. package/dist/theme.js +128 -0
  62. package/dist/types.d.ts +6 -0
  63. package/dist/types.js +1 -0
  64. package/dist/ui-constants.d.ts +24 -0
  65. package/dist/ui-constants.js +22 -0
  66. package/dist/ui-stylesheet.d.ts +8 -0
  67. package/dist/ui-stylesheet.js +223 -0
  68. package/dist/ui.d.ts +6 -0
  69. package/dist/ui.js +16 -0
  70. package/dist-cjs/agent-loop.js +83 -0
  71. package/dist-cjs/broker-validation.js +109 -0
  72. package/dist-cjs/broker.js +120 -0
  73. package/dist-cjs/constants.js +248 -0
  74. package/dist-cjs/context.js +54 -0
  75. package/dist-cjs/contribution-types.js +2 -0
  76. package/dist-cjs/core-types.js +2 -0
  77. package/dist-cjs/docs-validation.js +97 -0
  78. package/dist-cjs/docs.js +121 -0
  79. package/dist-cjs/index.js +56 -0
  80. package/dist-cjs/internal-validation.js +30 -0
  81. package/dist-cjs/json.js +39 -0
  82. package/dist-cjs/manifest-contributions.js +111 -0
  83. package/dist-cjs/manifest-primitives.js +158 -0
  84. package/dist-cjs/manifest.js +140 -0
  85. package/dist-cjs/openwaggle-sdk.js +130 -0
  86. package/dist-cjs/openwaggle-types.js +2 -0
  87. package/dist-cjs/openwaggle-validation.js +148 -0
  88. package/dist-cjs/package.json +3 -0
  89. package/dist-cjs/registry-types.js +2 -0
  90. package/dist-cjs/runtime-sdk.js +22 -0
  91. package/dist-cjs/runtime-types.js +2 -0
  92. package/dist-cjs/runtime.js +61 -0
  93. package/dist-cjs/schema.js +61 -0
  94. package/dist-cjs/sdk-types.js +2 -0
  95. package/dist-cjs/storage-sdk.js +54 -0
  96. package/dist-cjs/storage-types.js +2 -0
  97. package/dist-cjs/theme-data.js +147 -0
  98. package/dist-cjs/theme-types.js +2 -0
  99. package/dist-cjs/theme.js +135 -0
  100. package/dist-cjs/types.js +2 -0
  101. package/dist-cjs/ui-constants.js +25 -0
  102. package/dist-cjs/ui-stylesheet.js +227 -0
  103. package/dist-cjs/ui.js +24 -0
  104. package/package.json +98 -8
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-07-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * implement OpenWaggle extension contribution host ([e813eb0](https://github.com/OpenWaggle/OpenWaggle/commit/e813eb0de79ecc57ce62f2bb52e7237d3715f4fa))
9
+
10
+ ## Changelog
11
+
12
+ This package is not published yet. Release Please will maintain future package release notes here.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OpenWaggle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @openwaggle/extension-sdk
2
+
3
+ Browser-safe OpenWaggle extension SDK schemas, types, manifest validation, broker helpers, theme tokens, and federated-module context helpers.
@@ -0,0 +1,128 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { type JsonValue } from './json.js';
3
+ export interface OpenWaggleToolCallSurfaceInput {
4
+ readonly surface: 'tool';
5
+ readonly toolCall: {
6
+ readonly id: string;
7
+ readonly name: string;
8
+ readonly input?: JsonValue;
9
+ };
10
+ readonly toolResult?: {
11
+ readonly ok: boolean;
12
+ readonly output?: JsonValue;
13
+ readonly error?: string;
14
+ };
15
+ }
16
+ export interface OpenWaggleCustomMessageSurfaceInput {
17
+ readonly surface: 'custom-message';
18
+ readonly message: {
19
+ readonly name: string;
20
+ readonly payload?: JsonValue;
21
+ };
22
+ }
23
+ export interface OpenWaggleInteractionSurfaceInput {
24
+ readonly surface: 'interaction';
25
+ readonly interaction: {
26
+ readonly id: string;
27
+ readonly customType: string;
28
+ readonly payload?: JsonValue;
29
+ };
30
+ }
31
+ export interface OpenWaggleTranscriptSurfaceInput {
32
+ readonly surface: 'transcript';
33
+ readonly transcript: {
34
+ readonly sessionId?: string;
35
+ readonly messageCount: number;
36
+ readonly payload?: JsonValue;
37
+ };
38
+ }
39
+ export interface OpenWaggleStatusSurfaceInput {
40
+ readonly surface: 'status';
41
+ readonly status: {
42
+ readonly label: string;
43
+ readonly payload?: JsonValue;
44
+ };
45
+ }
46
+ export type OpenWaggleAgentLoopSurfaceInput = OpenWaggleToolCallSurfaceInput | OpenWaggleCustomMessageSurfaceInput | OpenWaggleInteractionSurfaceInput | OpenWaggleTranscriptSurfaceInput | OpenWaggleStatusSurfaceInput;
47
+ export declare const openWaggleToolCallSurfaceInputSchema: Schema.Struct<{
48
+ surface: Schema.Literal<["tool"]>;
49
+ toolCall: Schema.Struct<{
50
+ id: Schema.filter<typeof Schema.String>;
51
+ name: Schema.filter<typeof Schema.String>;
52
+ input: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
53
+ }>;
54
+ toolResult: Schema.optional<Schema.Struct<{
55
+ ok: typeof Schema.Boolean;
56
+ output: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
57
+ error: Schema.optional<typeof Schema.String>;
58
+ }>>;
59
+ }>;
60
+ export declare const openWaggleCustomMessageSurfaceInputSchema: Schema.Struct<{
61
+ surface: Schema.Literal<["custom-message"]>;
62
+ message: Schema.Struct<{
63
+ name: Schema.filter<typeof Schema.String>;
64
+ payload: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
65
+ }>;
66
+ }>;
67
+ export declare const openWaggleInteractionSurfaceInputSchema: Schema.Struct<{
68
+ surface: Schema.Literal<["interaction"]>;
69
+ interaction: Schema.Struct<{
70
+ id: Schema.filter<typeof Schema.String>;
71
+ customType: Schema.filter<typeof Schema.String>;
72
+ payload: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
73
+ }>;
74
+ }>;
75
+ export declare const openWaggleTranscriptSurfaceInputSchema: Schema.Struct<{
76
+ surface: Schema.Literal<["transcript"]>;
77
+ transcript: Schema.Struct<{
78
+ sessionId: Schema.optional<Schema.filter<typeof Schema.String>>;
79
+ messageCount: typeof Schema.Number;
80
+ payload: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
81
+ }>;
82
+ }>;
83
+ export declare const openWaggleStatusSurfaceInputSchema: Schema.Struct<{
84
+ surface: Schema.Literal<["status"]>;
85
+ status: Schema.Struct<{
86
+ label: Schema.filter<typeof Schema.String>;
87
+ payload: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
88
+ }>;
89
+ }>;
90
+ export declare const openWaggleAgentLoopSurfaceInputSchema: Schema.Union<[Schema.Struct<{
91
+ surface: Schema.Literal<["tool"]>;
92
+ toolCall: Schema.Struct<{
93
+ id: Schema.filter<typeof Schema.String>;
94
+ name: Schema.filter<typeof Schema.String>;
95
+ input: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
96
+ }>;
97
+ toolResult: Schema.optional<Schema.Struct<{
98
+ ok: typeof Schema.Boolean;
99
+ output: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
100
+ error: Schema.optional<typeof Schema.String>;
101
+ }>>;
102
+ }>, Schema.Struct<{
103
+ surface: Schema.Literal<["custom-message"]>;
104
+ message: Schema.Struct<{
105
+ name: Schema.filter<typeof Schema.String>;
106
+ payload: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
107
+ }>;
108
+ }>, Schema.Struct<{
109
+ surface: Schema.Literal<["interaction"]>;
110
+ interaction: Schema.Struct<{
111
+ id: Schema.filter<typeof Schema.String>;
112
+ customType: Schema.filter<typeof Schema.String>;
113
+ payload: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
114
+ }>;
115
+ }>, Schema.Struct<{
116
+ surface: Schema.Literal<["transcript"]>;
117
+ transcript: Schema.Struct<{
118
+ sessionId: Schema.optional<Schema.filter<typeof Schema.String>>;
119
+ messageCount: typeof Schema.Number;
120
+ payload: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
121
+ }>;
122
+ }>, Schema.Struct<{
123
+ surface: Schema.Literal<["status"]>;
124
+ status: Schema.Struct<{
125
+ label: Schema.filter<typeof Schema.String>;
126
+ payload: Schema.optional<Schema.Schema<JsonValue, JsonValue, never>>;
127
+ }>;
128
+ }>]>;
@@ -0,0 +1,47 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { jsonValueSchema } from './json.js';
3
+ const nonEmptyStringSchema = Schema.String.pipe(Schema.minLength(1));
4
+ export const openWaggleToolCallSurfaceInputSchema = Schema.Struct({
5
+ surface: Schema.Literal('tool'),
6
+ toolCall: Schema.Struct({
7
+ id: nonEmptyStringSchema,
8
+ name: nonEmptyStringSchema,
9
+ input: Schema.optional(jsonValueSchema),
10
+ }),
11
+ toolResult: Schema.optional(Schema.Struct({
12
+ ok: Schema.Boolean,
13
+ output: Schema.optional(jsonValueSchema),
14
+ error: Schema.optional(Schema.String),
15
+ })),
16
+ });
17
+ export const openWaggleCustomMessageSurfaceInputSchema = Schema.Struct({
18
+ surface: Schema.Literal('custom-message'),
19
+ message: Schema.Struct({
20
+ name: nonEmptyStringSchema,
21
+ payload: Schema.optional(jsonValueSchema),
22
+ }),
23
+ });
24
+ export const openWaggleInteractionSurfaceInputSchema = Schema.Struct({
25
+ surface: Schema.Literal('interaction'),
26
+ interaction: Schema.Struct({
27
+ id: nonEmptyStringSchema,
28
+ customType: nonEmptyStringSchema,
29
+ payload: Schema.optional(jsonValueSchema),
30
+ }),
31
+ });
32
+ export const openWaggleTranscriptSurfaceInputSchema = Schema.Struct({
33
+ surface: Schema.Literal('transcript'),
34
+ transcript: Schema.Struct({
35
+ sessionId: Schema.optional(nonEmptyStringSchema),
36
+ messageCount: Schema.Number,
37
+ payload: Schema.optional(jsonValueSchema),
38
+ }),
39
+ });
40
+ export const openWaggleStatusSurfaceInputSchema = Schema.Struct({
41
+ surface: Schema.Literal('status'),
42
+ status: Schema.Struct({
43
+ label: nonEmptyStringSchema,
44
+ payload: Schema.optional(jsonValueSchema),
45
+ }),
46
+ });
47
+ export const openWaggleAgentLoopSurfaceInputSchema = Schema.Union(openWaggleToolCallSurfaceInputSchema, openWaggleCustomMessageSurfaceInputSchema, openWaggleInteractionSurfaceInputSchema, openWaggleTranscriptSurfaceInputSchema, openWaggleStatusSurfaceInputSchema);
@@ -0,0 +1,17 @@
1
+ import type { ExtensionRuntimeRegisterContributionResult, ExtensionRuntimeUnregisterContributionResult } from './runtime-types.js';
2
+ import type { ExtensionStorageDeleteResult, ExtensionStorageGetResult, ExtensionStorageListResult, ExtensionStorageSetResult } from './storage-types.js';
3
+ import type { ExtensionCapabilityAuditEntry, ExtensionInvokeFailure, ExtensionInvokeResult } from './types.js';
4
+ type OperationResultGuard<TValue> = (value: unknown) => value is TValue;
5
+ export declare function invalidOperationResult(input: {
6
+ readonly audit: ExtensionCapabilityAuditEntry;
7
+ readonly issues: readonly string[];
8
+ readonly message: string;
9
+ }): ExtensionInvokeFailure;
10
+ export declare function toDecodedOperationResult<TValue>(result: ExtensionInvokeResult, guard: OperationResultGuard<TValue>, message: string): ExtensionInvokeResult<TValue>;
11
+ export declare function isStorageGetResult(value: unknown): value is ExtensionStorageGetResult;
12
+ export declare function isStorageSetResult(value: unknown): value is ExtensionStorageSetResult;
13
+ export declare function isStorageDeleteResult(value: unknown): value is ExtensionStorageDeleteResult;
14
+ export declare function isStorageListResult(value: unknown): value is ExtensionStorageListResult;
15
+ export declare function isRuntimeRegisterContributionResult(value: unknown): value is ExtensionRuntimeRegisterContributionResult;
16
+ export declare function isRuntimeUnregisterContributionResult(value: unknown): value is ExtensionRuntimeUnregisterContributionResult;
17
+ export {};
@@ -0,0 +1,99 @@
1
+ import { OPENWAGGLE_EXTENSION, OPENWAGGLE_EXTENSION_BROKER } from './constants.js';
2
+ import { isJsonValue, isNonEmptyString, isRecord, isStringArray } from './internal-validation.js';
3
+ export function invalidOperationResult(input) {
4
+ return {
5
+ ok: false,
6
+ error: {
7
+ code: OPENWAGGLE_EXTENSION_BROKER.FAILURE_CODE.INVALID_PAYLOAD,
8
+ message: input.message,
9
+ issues: [...input.issues],
10
+ },
11
+ audit: input.audit,
12
+ };
13
+ }
14
+ export function toDecodedOperationResult(result, guard, message) {
15
+ if (!result.ok) {
16
+ return result;
17
+ }
18
+ return guard(result.value)
19
+ ? { ok: true, value: result.value, audit: result.audit }
20
+ : invalidOperationResult({
21
+ audit: result.audit,
22
+ issues: ['Broker response payload did not match the expected operation result.'],
23
+ message,
24
+ });
25
+ }
26
+ function isKnownString(values, value) {
27
+ return typeof value === 'string' && values.some((candidate) => candidate === value);
28
+ }
29
+ function isStorageScope(value) {
30
+ if (!isRecord(value)) {
31
+ return false;
32
+ }
33
+ if (value.kind === OPENWAGGLE_EXTENSION.STORAGE.SCOPE.GLOBAL_KIND) {
34
+ return true;
35
+ }
36
+ return (value.kind === OPENWAGGLE_EXTENSION.STORAGE.SCOPE.PROJECT_KIND &&
37
+ isNonEmptyString(value.projectPath));
38
+ }
39
+ function isStorageKey(value) {
40
+ return (isNonEmptyString(value) &&
41
+ value === value.trim() &&
42
+ value.length <= OPENWAGGLE_EXTENSION.STORAGE.KEY_MAX_LENGTH);
43
+ }
44
+ function hasStorageResultBase(value) {
45
+ return (isNonEmptyString(value.extensionId) &&
46
+ isNonEmptyString(value.contributionId) &&
47
+ value.capability === OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STORAGE &&
48
+ isKnownString(OPENWAGGLE_EXTENSION.STORAGE.KINDS, value.storageKind) &&
49
+ isStorageScope(value.storageScope));
50
+ }
51
+ export function isStorageGetResult(value) {
52
+ return (isRecord(value) &&
53
+ hasStorageResultBase(value) &&
54
+ value.method === OPENWAGGLE_EXTENSION_BROKER.METHOD.GET &&
55
+ isStorageKey(value.key) &&
56
+ (value.value === null || isJsonValue(value.value)));
57
+ }
58
+ export function isStorageSetResult(value) {
59
+ return (isRecord(value) &&
60
+ hasStorageResultBase(value) &&
61
+ value.method === OPENWAGGLE_EXTENSION_BROKER.METHOD.SET &&
62
+ isStorageKey(value.key) &&
63
+ isJsonValue(value.value) &&
64
+ typeof value.createdAt === 'number' &&
65
+ typeof value.updatedAt === 'number');
66
+ }
67
+ export function isStorageDeleteResult(value) {
68
+ return (isRecord(value) &&
69
+ hasStorageResultBase(value) &&
70
+ value.method === OPENWAGGLE_EXTENSION_BROKER.METHOD.DELETE &&
71
+ isStorageKey(value.key) &&
72
+ value.deleted === true);
73
+ }
74
+ export function isStorageListResult(value) {
75
+ return (isRecord(value) &&
76
+ hasStorageResultBase(value) &&
77
+ value.method === OPENWAGGLE_EXTENSION_BROKER.METHOD.LIST &&
78
+ isStringArray(value.keys) &&
79
+ value.keys.every(isStorageKey));
80
+ }
81
+ function hasRuntimeContributionResultBase(value) {
82
+ return (isNonEmptyString(value.extensionId) &&
83
+ isNonEmptyString(value.contributionId) &&
84
+ value.capability === OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.RUNTIME &&
85
+ isKnownString(OPENWAGGLE_EXTENSION.CONTRIBUTION_FAMILIES, value.family));
86
+ }
87
+ export function isRuntimeRegisterContributionResult(value) {
88
+ return (isRecord(value) &&
89
+ hasRuntimeContributionResultBase(value) &&
90
+ value.method === OPENWAGGLE_EXTENSION_BROKER.METHOD.REGISTER_CONTRIBUTION &&
91
+ isNonEmptyString(value.registeredContributionId));
92
+ }
93
+ export function isRuntimeUnregisterContributionResult(value) {
94
+ return (isRecord(value) &&
95
+ hasRuntimeContributionResultBase(value) &&
96
+ value.method === OPENWAGGLE_EXTENSION_BROKER.METHOD.UNREGISTER_CONTRIBUTION &&
97
+ isNonEmptyString(value.unregisteredContributionId) &&
98
+ typeof value.unregistered === 'boolean');
99
+ }
@@ -0,0 +1,193 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import type { CreateOpenWaggleSdkOptions, ExtensionBrokerSdk, ExtensionBrokerTransport, ExtensionSdkIdentity, ExtensionSdkInvoke, ExtensionSdkInvokeRequest } from './sdk-types.js';
3
+ import type { ExtensionInvokeInput } from './types.js';
4
+ export type * from './core-types.js';
5
+ export type * from './sdk-types.js';
6
+ export declare const extensionInvokeScopeSchema: Schema.Union<[Schema.Struct<{
7
+ kind: Schema.Literal<["app"]>;
8
+ }>, Schema.Struct<{
9
+ kind: Schema.Literal<["project"]>;
10
+ projectPath: Schema.filter<typeof Schema.String>;
11
+ }>, Schema.Struct<{
12
+ kind: Schema.Literal<["session"]>;
13
+ projectPath: Schema.filter<typeof Schema.String>;
14
+ sessionId: Schema.filter<typeof Schema.String>;
15
+ }>, Schema.Struct<{
16
+ kind: Schema.Literal<["branch"]>;
17
+ projectPath: Schema.filter<typeof Schema.String>;
18
+ sessionId: Schema.filter<typeof Schema.String>;
19
+ branchId: Schema.filter<typeof Schema.String>;
20
+ }>]>;
21
+ export declare const extensionCapabilityAuditEntrySchema: Schema.Struct<{
22
+ extensionId: Schema.filter<Schema.filter<typeof Schema.String>>;
23
+ contributionId: Schema.filter<Schema.filter<typeof Schema.String>>;
24
+ capability: Schema.filter<Schema.filter<typeof Schema.String>>;
25
+ method: Schema.filter<Schema.filter<typeof Schema.String>>;
26
+ scope: Schema.Union<[Schema.Struct<{
27
+ kind: Schema.Literal<["app"]>;
28
+ }>, Schema.Struct<{
29
+ kind: Schema.Literal<["project"]>;
30
+ projectPath: Schema.filter<typeof Schema.String>;
31
+ }>, Schema.Struct<{
32
+ kind: Schema.Literal<["session"]>;
33
+ projectPath: Schema.filter<typeof Schema.String>;
34
+ sessionId: Schema.filter<typeof Schema.String>;
35
+ }>, Schema.Struct<{
36
+ kind: Schema.Literal<["branch"]>;
37
+ projectPath: Schema.filter<typeof Schema.String>;
38
+ sessionId: Schema.filter<typeof Schema.String>;
39
+ branchId: Schema.filter<typeof Schema.String>;
40
+ }>]>;
41
+ outcome: Schema.SchemaClass<"succeeded" | "rejected", "succeeded" | "rejected", never>;
42
+ timestamp: typeof Schema.Number;
43
+ failureCode: Schema.optional<Schema.SchemaClass<"invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", "invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", never>>;
44
+ }>;
45
+ export declare const extensionInvokeInputSchema: Schema.Struct<{
46
+ extensionId: Schema.filter<Schema.filter<typeof Schema.String>>;
47
+ contributionId: Schema.filter<Schema.filter<typeof Schema.String>>;
48
+ capability: Schema.filter<Schema.filter<typeof Schema.String>>;
49
+ method: Schema.filter<Schema.filter<typeof Schema.String>>;
50
+ scope: Schema.Union<[Schema.Struct<{
51
+ kind: Schema.Literal<["app"]>;
52
+ }>, Schema.Struct<{
53
+ kind: Schema.Literal<["project"]>;
54
+ projectPath: Schema.filter<typeof Schema.String>;
55
+ }>, Schema.Struct<{
56
+ kind: Schema.Literal<["session"]>;
57
+ projectPath: Schema.filter<typeof Schema.String>;
58
+ sessionId: Schema.filter<typeof Schema.String>;
59
+ }>, Schema.Struct<{
60
+ kind: Schema.Literal<["branch"]>;
61
+ projectPath: Schema.filter<typeof Schema.String>;
62
+ sessionId: Schema.filter<typeof Schema.String>;
63
+ branchId: Schema.filter<typeof Schema.String>;
64
+ }>]>;
65
+ payload: Schema.optional<typeof Schema.Unknown>;
66
+ }>;
67
+ export declare const extensionInvokeErrorSchema: Schema.Struct<{
68
+ code: Schema.SchemaClass<"invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", "invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", never>;
69
+ message: Schema.filter<typeof Schema.String>;
70
+ issues: Schema.optional<Schema.Array$<typeof Schema.String>>;
71
+ }>;
72
+ export declare const extensionInvokeSuccessSchema: Schema.Struct<{
73
+ ok: Schema.Literal<[true]>;
74
+ value: typeof Schema.Unknown;
75
+ audit: Schema.Struct<{
76
+ extensionId: Schema.filter<Schema.filter<typeof Schema.String>>;
77
+ contributionId: Schema.filter<Schema.filter<typeof Schema.String>>;
78
+ capability: Schema.filter<Schema.filter<typeof Schema.String>>;
79
+ method: Schema.filter<Schema.filter<typeof Schema.String>>;
80
+ scope: Schema.Union<[Schema.Struct<{
81
+ kind: Schema.Literal<["app"]>;
82
+ }>, Schema.Struct<{
83
+ kind: Schema.Literal<["project"]>;
84
+ projectPath: Schema.filter<typeof Schema.String>;
85
+ }>, Schema.Struct<{
86
+ kind: Schema.Literal<["session"]>;
87
+ projectPath: Schema.filter<typeof Schema.String>;
88
+ sessionId: Schema.filter<typeof Schema.String>;
89
+ }>, Schema.Struct<{
90
+ kind: Schema.Literal<["branch"]>;
91
+ projectPath: Schema.filter<typeof Schema.String>;
92
+ sessionId: Schema.filter<typeof Schema.String>;
93
+ branchId: Schema.filter<typeof Schema.String>;
94
+ }>]>;
95
+ outcome: Schema.SchemaClass<"succeeded" | "rejected", "succeeded" | "rejected", never>;
96
+ timestamp: typeof Schema.Number;
97
+ failureCode: Schema.optional<Schema.SchemaClass<"invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", "invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", never>>;
98
+ }>;
99
+ }>;
100
+ export declare const extensionInvokeFailureSchema: Schema.Struct<{
101
+ ok: Schema.Literal<[false]>;
102
+ error: Schema.Struct<{
103
+ code: Schema.SchemaClass<"invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", "invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", never>;
104
+ message: Schema.filter<typeof Schema.String>;
105
+ issues: Schema.optional<Schema.Array$<typeof Schema.String>>;
106
+ }>;
107
+ audit: Schema.optional<Schema.Struct<{
108
+ extensionId: Schema.filter<Schema.filter<typeof Schema.String>>;
109
+ contributionId: Schema.filter<Schema.filter<typeof Schema.String>>;
110
+ capability: Schema.filter<Schema.filter<typeof Schema.String>>;
111
+ method: Schema.filter<Schema.filter<typeof Schema.String>>;
112
+ scope: Schema.Union<[Schema.Struct<{
113
+ kind: Schema.Literal<["app"]>;
114
+ }>, Schema.Struct<{
115
+ kind: Schema.Literal<["project"]>;
116
+ projectPath: Schema.filter<typeof Schema.String>;
117
+ }>, Schema.Struct<{
118
+ kind: Schema.Literal<["session"]>;
119
+ projectPath: Schema.filter<typeof Schema.String>;
120
+ sessionId: Schema.filter<typeof Schema.String>;
121
+ }>, Schema.Struct<{
122
+ kind: Schema.Literal<["branch"]>;
123
+ projectPath: Schema.filter<typeof Schema.String>;
124
+ sessionId: Schema.filter<typeof Schema.String>;
125
+ branchId: Schema.filter<typeof Schema.String>;
126
+ }>]>;
127
+ outcome: Schema.SchemaClass<"succeeded" | "rejected", "succeeded" | "rejected", never>;
128
+ timestamp: typeof Schema.Number;
129
+ failureCode: Schema.optional<Schema.SchemaClass<"invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", "invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", never>>;
130
+ }>>;
131
+ }>;
132
+ export declare const extensionInvokeResultSchema: Schema.Union<[Schema.Struct<{
133
+ ok: Schema.Literal<[true]>;
134
+ value: typeof Schema.Unknown;
135
+ audit: Schema.Struct<{
136
+ extensionId: Schema.filter<Schema.filter<typeof Schema.String>>;
137
+ contributionId: Schema.filter<Schema.filter<typeof Schema.String>>;
138
+ capability: Schema.filter<Schema.filter<typeof Schema.String>>;
139
+ method: Schema.filter<Schema.filter<typeof Schema.String>>;
140
+ scope: Schema.Union<[Schema.Struct<{
141
+ kind: Schema.Literal<["app"]>;
142
+ }>, Schema.Struct<{
143
+ kind: Schema.Literal<["project"]>;
144
+ projectPath: Schema.filter<typeof Schema.String>;
145
+ }>, Schema.Struct<{
146
+ kind: Schema.Literal<["session"]>;
147
+ projectPath: Schema.filter<typeof Schema.String>;
148
+ sessionId: Schema.filter<typeof Schema.String>;
149
+ }>, Schema.Struct<{
150
+ kind: Schema.Literal<["branch"]>;
151
+ projectPath: Schema.filter<typeof Schema.String>;
152
+ sessionId: Schema.filter<typeof Schema.String>;
153
+ branchId: Schema.filter<typeof Schema.String>;
154
+ }>]>;
155
+ outcome: Schema.SchemaClass<"succeeded" | "rejected", "succeeded" | "rejected", never>;
156
+ timestamp: typeof Schema.Number;
157
+ failureCode: Schema.optional<Schema.SchemaClass<"invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", "invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", never>>;
158
+ }>;
159
+ }>, Schema.Struct<{
160
+ ok: Schema.Literal<[false]>;
161
+ error: Schema.Struct<{
162
+ code: Schema.SchemaClass<"invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", "invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", never>;
163
+ message: Schema.filter<typeof Schema.String>;
164
+ issues: Schema.optional<Schema.Array$<typeof Schema.String>>;
165
+ }>;
166
+ audit: Schema.optional<Schema.Struct<{
167
+ extensionId: Schema.filter<Schema.filter<typeof Schema.String>>;
168
+ contributionId: Schema.filter<Schema.filter<typeof Schema.String>>;
169
+ capability: Schema.filter<Schema.filter<typeof Schema.String>>;
170
+ method: Schema.filter<Schema.filter<typeof Schema.String>>;
171
+ scope: Schema.Union<[Schema.Struct<{
172
+ kind: Schema.Literal<["app"]>;
173
+ }>, Schema.Struct<{
174
+ kind: Schema.Literal<["project"]>;
175
+ projectPath: Schema.filter<typeof Schema.String>;
176
+ }>, Schema.Struct<{
177
+ kind: Schema.Literal<["session"]>;
178
+ projectPath: Schema.filter<typeof Schema.String>;
179
+ sessionId: Schema.filter<typeof Schema.String>;
180
+ }>, Schema.Struct<{
181
+ kind: Schema.Literal<["branch"]>;
182
+ projectPath: Schema.filter<typeof Schema.String>;
183
+ sessionId: Schema.filter<typeof Schema.String>;
184
+ branchId: Schema.filter<typeof Schema.String>;
185
+ }>]>;
186
+ outcome: Schema.SchemaClass<"succeeded" | "rejected", "succeeded" | "rejected", never>;
187
+ timestamp: typeof Schema.Number;
188
+ failureCode: Schema.optional<Schema.SchemaClass<"invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", "invalid-input" | "invalid-payload" | "unknown-extension" | "disabled-extension" | "unknown-contribution" | "undeclared-capability" | "undeclared-method" | "undeclared-scope" | "out-of-scope" | "unsupported-capability" | "unsupported-method" | "transport-failed", never>>;
189
+ }>>;
190
+ }>]>;
191
+ export declare function toInvokeInput(identity: ExtensionSdkIdentity, request: ExtensionSdkInvokeRequest): ExtensionInvokeInput;
192
+ export declare function createExtensionBrokerSdkFromInvoke(invoke: ExtensionSdkInvoke, options?: CreateOpenWaggleSdkOptions): ExtensionBrokerSdk;
193
+ export declare function createExtensionBrokerSdk(transport: ExtensionBrokerTransport, identity: ExtensionSdkIdentity, options?: CreateOpenWaggleSdkOptions): ExtensionBrokerSdk;
package/dist/broker.js ADDED
@@ -0,0 +1,81 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { OPENWAGGLE_EXTENSION_BROKER } from './constants.js';
3
+ import { extensionContributionIdSchema, extensionIdSchema } from './manifest.js';
4
+ import { createOpenWaggleSdk } from './openwaggle-sdk.js';
5
+ import { createRuntimeContributionSdk } from './runtime-sdk.js';
6
+ import { createPackageStorageSdk } from './storage-sdk.js';
7
+ const nonEmptyStringSchema = Schema.String.pipe(Schema.minLength(1));
8
+ export const extensionInvokeScopeSchema = Schema.Union(Schema.Struct({ kind: Schema.Literal('app') }), Schema.Struct({ kind: Schema.Literal('project'), projectPath: nonEmptyStringSchema }), Schema.Struct({
9
+ kind: Schema.Literal('session'),
10
+ projectPath: nonEmptyStringSchema,
11
+ sessionId: nonEmptyStringSchema,
12
+ }), Schema.Struct({
13
+ kind: Schema.Literal('branch'),
14
+ projectPath: nonEmptyStringSchema,
15
+ sessionId: nonEmptyStringSchema,
16
+ branchId: nonEmptyStringSchema,
17
+ }));
18
+ export const extensionCapabilityAuditEntrySchema = Schema.Struct({
19
+ extensionId: extensionIdSchema,
20
+ contributionId: extensionContributionIdSchema,
21
+ capability: extensionContributionIdSchema,
22
+ method: extensionContributionIdSchema,
23
+ scope: extensionInvokeScopeSchema,
24
+ outcome: Schema.Literal(...OPENWAGGLE_EXTENSION_BROKER.OUTCOMES),
25
+ timestamp: Schema.Number,
26
+ failureCode: Schema.optional(Schema.Literal(...OPENWAGGLE_EXTENSION_BROKER.FAILURE_CODES)),
27
+ });
28
+ export const extensionInvokeInputSchema = Schema.Struct({
29
+ extensionId: extensionIdSchema,
30
+ contributionId: extensionContributionIdSchema,
31
+ capability: extensionContributionIdSchema,
32
+ method: extensionContributionIdSchema,
33
+ scope: extensionInvokeScopeSchema,
34
+ payload: Schema.optional(Schema.Unknown),
35
+ });
36
+ export const extensionInvokeErrorSchema = Schema.Struct({
37
+ code: Schema.Literal(...OPENWAGGLE_EXTENSION_BROKER.FAILURE_CODES),
38
+ message: nonEmptyStringSchema,
39
+ issues: Schema.optional(Schema.Array(Schema.String)),
40
+ });
41
+ export const extensionInvokeSuccessSchema = Schema.Struct({
42
+ ok: Schema.Literal(true),
43
+ value: Schema.Unknown,
44
+ audit: extensionCapabilityAuditEntrySchema,
45
+ });
46
+ export const extensionInvokeFailureSchema = Schema.Struct({
47
+ ok: Schema.Literal(false),
48
+ error: extensionInvokeErrorSchema,
49
+ audit: Schema.optional(extensionCapabilityAuditEntrySchema),
50
+ });
51
+ export const extensionInvokeResultSchema = Schema.Union(extensionInvokeSuccessSchema, extensionInvokeFailureSchema);
52
+ export function toInvokeInput(identity, request) {
53
+ return {
54
+ extensionId: identity.extensionId,
55
+ contributionId: identity.contributionId,
56
+ capability: request.capability,
57
+ method: request.method,
58
+ scope: request.scope,
59
+ ...(request.payload !== undefined ? { payload: request.payload } : {}),
60
+ };
61
+ }
62
+ export function createExtensionBrokerSdkFromInvoke(invoke, options = {}) {
63
+ return {
64
+ invoke,
65
+ hostContext: {
66
+ getScope: (scope) => invoke({
67
+ capability: OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.HOST_CONTEXT,
68
+ method: OPENWAGGLE_EXTENSION_BROKER.METHOD.GET_SCOPE,
69
+ scope,
70
+ payload: {},
71
+ }),
72
+ },
73
+ storage: createPackageStorageSdk(invoke),
74
+ openWaggle: createOpenWaggleSdk(invoke, options),
75
+ runtime: createRuntimeContributionSdk(invoke),
76
+ };
77
+ }
78
+ export function createExtensionBrokerSdk(transport, identity, options = {}) {
79
+ const invoke = (request) => transport(toInvokeInput(identity, request));
80
+ return createExtensionBrokerSdkFromInvoke(invoke, options);
81
+ }