@principal-ai/control-tower-core 0.1.6 → 0.1.7
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 +63 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -19
- package/dist/index.js.map +7 -5
- package/dist/index.mjs +178 -2
- package/dist/index.mjs.map +7 -5
- package/dist/server/BaseServer.d.ts +13 -1
- package/dist/server/BaseServer.d.ts.map +1 -1
- package/dist/server/BaseServer.js +15 -0
- package/dist/server/ExperimentalAPI.d.ts +137 -0
- package/dist/server/ExperimentalAPI.d.ts.map +1 -0
- package/dist/server/ExperimentalAPI.js +239 -0
- package/dist/server/ServerBuilder.d.ts +11 -1
- package/dist/server/ServerBuilder.d.ts.map +1 -1
- package/dist/server/ServerBuilder.js +18 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -1
- package/dist/types/experimental.d.ts +136 -0
- package/dist/types/experimental.d.ts.map +1 -0
- package/dist/types/experimental.js +32 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experimental API Types
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ WARNING: Types in this file are experimental and may change or be removed
|
|
5
|
+
* without major version bumps. Use only for prototyping and internal tooling.
|
|
6
|
+
*
|
|
7
|
+
* For production use, submit a feature request to graduate these APIs:
|
|
8
|
+
* @see docs/FEATURE_REQUEST_TEMPLATE.md
|
|
9
|
+
*/
|
|
10
|
+
import type { ConnectedClient } from '../server/BaseServer.js';
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for experimental features
|
|
13
|
+
*/
|
|
14
|
+
export interface ExperimentalFeatureConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Enable experimental broadcast APIs
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ DEVELOPMENT USE ONLY
|
|
19
|
+
* Allows use of server.experimental.broadcast() and related methods
|
|
20
|
+
*
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
enableBroadcast?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Enable runtime warnings for experimental API usage
|
|
26
|
+
*
|
|
27
|
+
* When true, logs warnings each time an experimental API is called
|
|
28
|
+
* Useful for tracking experimental API usage in development
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
warnOnExperimentalUse?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Track experimental API usage metrics
|
|
35
|
+
*
|
|
36
|
+
* When true, emits events for experimental API calls that can be
|
|
37
|
+
* monitored to understand usage patterns
|
|
38
|
+
*
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
trackUsageMetrics?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Client predicate function for filtering broadcasts
|
|
45
|
+
*
|
|
46
|
+
* @param client - The connected client to evaluate
|
|
47
|
+
* @returns true if the client should receive the broadcast
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Broadcast only to admin users
|
|
51
|
+
* const isAdmin: ClientPredicate = (client) => {
|
|
52
|
+
* return getUserRole(client.userId) === 'admin';
|
|
53
|
+
* };
|
|
54
|
+
*/
|
|
55
|
+
export type ClientPredicate = (client: ConnectedClient) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Result of a broadcast operation
|
|
58
|
+
*/
|
|
59
|
+
export interface BroadcastResult {
|
|
60
|
+
/**
|
|
61
|
+
* Number of clients that successfully received the message
|
|
62
|
+
*/
|
|
63
|
+
sent: number;
|
|
64
|
+
/**
|
|
65
|
+
* Number of clients that failed to receive the message
|
|
66
|
+
*/
|
|
67
|
+
failed: number;
|
|
68
|
+
/**
|
|
69
|
+
* Errors that occurred during broadcast
|
|
70
|
+
*/
|
|
71
|
+
errors: Array<{
|
|
72
|
+
clientId: string;
|
|
73
|
+
error: Error;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Total time taken to complete the broadcast (milliseconds)
|
|
77
|
+
*/
|
|
78
|
+
durationMs: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Options for broadcast operations
|
|
82
|
+
*/
|
|
83
|
+
export interface BroadcastOptions {
|
|
84
|
+
/**
|
|
85
|
+
* Whether to continue broadcasting even if some sends fail
|
|
86
|
+
*
|
|
87
|
+
* @default true
|
|
88
|
+
*/
|
|
89
|
+
continueOnError?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Timeout for each individual send operation (milliseconds)
|
|
92
|
+
*
|
|
93
|
+
* @default 5000
|
|
94
|
+
*/
|
|
95
|
+
sendTimeout?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Whether to include detailed error information in the result
|
|
98
|
+
*
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
includeErrors?: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Experimental API usage metrics event
|
|
105
|
+
*/
|
|
106
|
+
export interface ExperimentalUsageEvent {
|
|
107
|
+
/**
|
|
108
|
+
* The experimental method that was called
|
|
109
|
+
*/
|
|
110
|
+
method: 'broadcast' | 'broadcastAuthenticated' | 'broadcastWhere' | 'sendToUsers';
|
|
111
|
+
/**
|
|
112
|
+
* Message type being broadcast
|
|
113
|
+
*/
|
|
114
|
+
messageType: string;
|
|
115
|
+
/**
|
|
116
|
+
* Number of recipients
|
|
117
|
+
*/
|
|
118
|
+
recipientCount: number;
|
|
119
|
+
/**
|
|
120
|
+
* Timestamp of the call
|
|
121
|
+
*/
|
|
122
|
+
timestamp: number;
|
|
123
|
+
/**
|
|
124
|
+
* Size of the message payload (bytes)
|
|
125
|
+
*/
|
|
126
|
+
payloadSize?: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Error thrown when experimental features are not enabled
|
|
130
|
+
*/
|
|
131
|
+
export declare class ExperimentalFeatureError extends Error {
|
|
132
|
+
readonly feature: string;
|
|
133
|
+
readonly configKey: keyof ExperimentalFeatureConfig;
|
|
134
|
+
constructor(feature: string, configKey: keyof ExperimentalFeatureConfig);
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=experimental.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experimental.d.ts","sourceRoot":"","sources":["../../src/types/experimental.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,KAAK,CAAC;KACd,CAAC,CAAC;IAEH;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,MAAM,EAAE,WAAW,GAAG,wBAAwB,GAAG,gBAAgB,GAAG,aAAa,CAAC;IAElF;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;aAE/B,OAAO,EAAE,MAAM;aACf,SAAS,EAAE,MAAM,yBAAyB;gBAD1C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,yBAAyB;CAe7D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Experimental API Types
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ WARNING: Types in this file are experimental and may change or be removed
|
|
6
|
+
* without major version bumps. Use only for prototyping and internal tooling.
|
|
7
|
+
*
|
|
8
|
+
* For production use, submit a feature request to graduate these APIs:
|
|
9
|
+
* @see docs/FEATURE_REQUEST_TEMPLATE.md
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ExperimentalFeatureError = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when experimental features are not enabled
|
|
15
|
+
*/
|
|
16
|
+
class ExperimentalFeatureError extends Error {
|
|
17
|
+
constructor(feature, configKey) {
|
|
18
|
+
super(`Experimental feature '${feature}' is not enabled.\n\n` +
|
|
19
|
+
`To enable, set '${String(configKey)}: true' in your server configuration:\n\n` +
|
|
20
|
+
` const server = new ServerBuilder()\n` +
|
|
21
|
+
` .withExperimentalFeatures({ ${String(configKey)}: true })\n` +
|
|
22
|
+
` .build();\n\n` +
|
|
23
|
+
`⚠️ WARNING: Experimental APIs are for development only.\n` +
|
|
24
|
+
`For production use, submit a feature request:\n` +
|
|
25
|
+
`https://github.com/your-org/control-tower-core/issues/new\n\n` +
|
|
26
|
+
`See docs/EXPERIMENTAL_BROADCAST.md for details.`);
|
|
27
|
+
this.feature = feature;
|
|
28
|
+
this.configKey = configKey;
|
|
29
|
+
this.name = 'ExperimentalFeatureError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ExperimentalFeatureError = ExperimentalFeatureError;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -20,4 +20,5 @@ export interface Message {
|
|
|
20
20
|
export type MessageHandler = (message: Message) => void | Promise<void>;
|
|
21
21
|
export type ErrorHandler = (error: Error) => void;
|
|
22
22
|
export type CloseHandler = (code: number, reason: string) => void;
|
|
23
|
+
export { ExperimentalFeatureConfig, ClientPredicate, BroadcastResult, BroadcastOptions, ExperimentalUsageEvent, ExperimentalFeatureError } from './experimental.js';
|
|
23
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,UAAU,EACV,eAAe,EACf,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,EACN,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,SAAS,EACT,WAAW,EACX,YAAY,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,cAAc,EACd,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACX,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,aAAa,EACb,SAAS,EACV,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,eAAe,GAAG,cAAc,CAAC;AAE5F,MAA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GAAG,YAAY,GAAG,WAAW,GAAG,eAAe,GAAG,cAAc,CAAC;AAE5F,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACxE,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAClD,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAElE,OAAO,EACL,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,mBAAmB,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExperimentalFeatureError = void 0;
|
|
4
|
+
var experimental_js_1 = require("./experimental.js");
|
|
5
|
+
Object.defineProperty(exports, "ExperimentalFeatureError", { enumerable: true, get: function () { return experimental_js_1.ExperimentalFeatureError; } });
|
package/package.json
CHANGED