@temps-sdk/plugin 0.1.0-beta.1

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/api.d.ts +33 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +96 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/auth.d.ts +41 -0
  8. package/dist/auth.d.ts.map +1 -0
  9. package/dist/auth.js +102 -0
  10. package/dist/auth.js.map +1 -0
  11. package/dist/client.d.ts +29 -0
  12. package/dist/client.d.ts.map +1 -0
  13. package/dist/client.js +141 -0
  14. package/dist/client.js.map +1 -0
  15. package/dist/context.d.ts +26 -0
  16. package/dist/context.d.ts.map +1 -0
  17. package/dist/context.js +52 -0
  18. package/dist/context.js.map +1 -0
  19. package/dist/errors.d.ts +61 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +115 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/index.d.ts +14 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +13 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/manifest-builder.d.ts +57 -0
  28. package/dist/manifest-builder.d.ts.map +1 -0
  29. package/dist/manifest-builder.js +118 -0
  30. package/dist/manifest-builder.js.map +1 -0
  31. package/dist/protocol.d.ts +22 -0
  32. package/dist/protocol.d.ts.map +1 -0
  33. package/dist/protocol.js +120 -0
  34. package/dist/protocol.js.map +1 -0
  35. package/dist/runtime.d.ts +14 -0
  36. package/dist/runtime.d.ts.map +1 -0
  37. package/dist/runtime.js +511 -0
  38. package/dist/runtime.js.map +1 -0
  39. package/dist/types.d.ts +252 -0
  40. package/dist/types.d.ts.map +1 -0
  41. package/dist/types.js +7 -0
  42. package/dist/types.js.map +1 -0
  43. package/dist/ui.d.ts +26 -0
  44. package/dist/ui.d.ts.map +1 -0
  45. package/dist/ui.js +186 -0
  46. package/dist/ui.js.map +1 -0
  47. package/package.json +55 -0
@@ -0,0 +1,52 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
3
+ import { PlatformApi } from "./api.js";
4
+ export class PluginContext {
5
+ #pluginName;
6
+ #dataDir;
7
+ #databaseUrl;
8
+ #hostDataDir;
9
+ #hostApiUrl;
10
+ #authSecret;
11
+ #client;
12
+ constructor(options) {
13
+ this.#pluginName = options.pluginName;
14
+ this.#dataDir = options.dataDir;
15
+ this.#databaseUrl = options.databaseUrl;
16
+ this.#hostDataDir = options.hostDataDir;
17
+ this.#hostApiUrl = options.hostApiUrl;
18
+ this.#authSecret = options.authSecret;
19
+ this.#client = options.client;
20
+ }
21
+ get temps() {
22
+ return this.#client;
23
+ }
24
+ apiAsCaller(caller) {
25
+ return new PlatformApi(this.#client, caller);
26
+ }
27
+ get pluginName() {
28
+ return this.#pluginName;
29
+ }
30
+ get dataDir() {
31
+ return this.#dataDir;
32
+ }
33
+ get databaseUrl() {
34
+ return this.#databaseUrl;
35
+ }
36
+ get hostDataDir() {
37
+ return this.#hostDataDir;
38
+ }
39
+ get hostApiUrl() {
40
+ return this.#hostApiUrl;
41
+ }
42
+ get mountUrl() {
43
+ return this.#hostApiUrl === undefined
44
+ ? undefined
45
+ : `${this.#hostApiUrl.replace(/\/$/, "")}/api/x/${this.#pluginName}`;
46
+ }
47
+ /** Per-process assertion secret. Prefer extractAuthContext over manual use. */
48
+ get authSecret() {
49
+ return this.#authSecret;
50
+ }
51
+ }
52
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,6CAA6C;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,MAAM,OAAO,aAAa;IACf,WAAW,CAAS;IACpB,QAAQ,CAAS;IACjB,YAAY,CAAU;IACt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OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Typed error hierarchy for the plugin SDK.
3
+ */
4
+ import type { ChannelErrorCode } from "./types.js";
5
+ export declare class PluginSdkError extends Error {
6
+ constructor(message: string);
7
+ }
8
+ export declare class ArgsError extends PluginSdkError {
9
+ constructor(message: string);
10
+ }
11
+ export declare class SocketBindError extends PluginSdkError {
12
+ readonly path: string;
13
+ readonly reason: string;
14
+ constructor(path: string, reason: string);
15
+ }
16
+ export declare class HandshakeError extends PluginSdkError {
17
+ readonly pluginName: string;
18
+ readonly reason: string;
19
+ constructor(pluginName: string, reason: string);
20
+ }
21
+ export declare class InitializationError extends PluginSdkError {
22
+ readonly pluginName: string;
23
+ readonly reason: string;
24
+ constructor(pluginName: string, reason: string);
25
+ }
26
+ export declare class ChannelClosedError extends PluginSdkError {
27
+ constructor();
28
+ }
29
+ export declare class PlatformError extends PluginSdkError {
30
+ readonly code: ChannelErrorCode;
31
+ constructor(code: ChannelErrorCode, message: string);
32
+ }
33
+ export declare class ChannelTimeoutError extends PluginSdkError {
34
+ readonly method: string;
35
+ readonly timeoutMs: number;
36
+ constructor(method: string, timeoutMs: number);
37
+ }
38
+ export declare class ProtocolMismatchError extends PluginSdkError {
39
+ readonly expectedMethod: string;
40
+ readonly receivedMethod: string;
41
+ constructor(expectedMethod: string, receivedMethod: string);
42
+ }
43
+ export declare class ActorTokenRequiredError extends PluginSdkError {
44
+ constructor();
45
+ }
46
+ export declare class CallBodyTooLargeError extends PluginSdkError {
47
+ readonly actualBytes: number;
48
+ readonly maximumBytes: number;
49
+ constructor(actualBytes: number, maximumBytes: number);
50
+ }
51
+ export declare class RequestBodyTooLargeError extends PluginSdkError {
52
+ readonly actualBytes: number;
53
+ readonly maximumBytes: number;
54
+ constructor(actualBytes: number, maximumBytes: number);
55
+ }
56
+ export declare class ResponseBodyTooLargeError extends PluginSdkError {
57
+ readonly actualBytes: number;
58
+ readonly maximumBytes: number;
59
+ constructor(actualBytes: number, maximumBytes: number);
60
+ }
61
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,SAAU,SAAQ,cAAc;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,cAAc;IACjD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAMzC;AAED,qBAAa,cAAe,SAAQ,cAAc;IAChD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM/C;AAED,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM/C;AAED,qBAAa,kBAAmB,SAAQ,cAAc;;CAKrD;AAED,qBAAa,aAAc,SAAQ,cAAc;IAC/C,SAAgB,IAAI,EAAE,gBAAgB,CAAC;gBAE3B,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM;CAKpD;AAED,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,SAAS,EAAE,MAAM,CAAC;gBAEtB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAM9C;AAED,qBAAa,qBAAsB,SAAQ,cAAc;IACvD,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAE3B,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAQ3D;AAED,qBAAa,uBAAwB,SAAQ,cAAc;;CAO1D;AAED,qBAAa,qBAAsB,SAAQ,cAAc;IACvD,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAEzB,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAQtD;AAED,qBAAa,wBAAyB,SAAQ,cAAc;IAC1D,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAEzB,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAQtD;AAED,qBAAa,yBAA0B,SAAQ,cAAc;IAC3D,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAEzB,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAQtD"}
package/dist/errors.js ADDED
@@ -0,0 +1,115 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
3
+ export class PluginSdkError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = "PluginSdkError";
7
+ }
8
+ }
9
+ export class ArgsError extends PluginSdkError {
10
+ constructor(message) {
11
+ super(`Argument error: ${message}`);
12
+ this.name = "ArgsError";
13
+ }
14
+ }
15
+ export class SocketBindError extends PluginSdkError {
16
+ path;
17
+ reason;
18
+ constructor(path, reason) {
19
+ super(`Failed to bind Unix socket at ${path}: ${reason}`);
20
+ this.name = "SocketBindError";
21
+ this.path = path;
22
+ this.reason = reason;
23
+ }
24
+ }
25
+ export class HandshakeError extends PluginSdkError {
26
+ pluginName;
27
+ reason;
28
+ constructor(pluginName, reason) {
29
+ super(`Handshake failed for plugin "${pluginName}": ${reason}`);
30
+ this.name = "HandshakeError";
31
+ this.pluginName = pluginName;
32
+ this.reason = reason;
33
+ }
34
+ }
35
+ export class InitializationError extends PluginSdkError {
36
+ pluginName;
37
+ reason;
38
+ constructor(pluginName, reason) {
39
+ super(`Initialization failed for plugin "${pluginName}": ${reason}`);
40
+ this.name = "InitializationError";
41
+ this.pluginName = pluginName;
42
+ this.reason = reason;
43
+ }
44
+ }
45
+ export class ChannelClosedError extends PluginSdkError {
46
+ constructor() {
47
+ super("Platform channel is closed");
48
+ this.name = "ChannelClosedError";
49
+ }
50
+ }
51
+ export class PlatformError extends PluginSdkError {
52
+ code;
53
+ constructor(code, message) {
54
+ super(`Platform error (${code}): ${message}`);
55
+ this.name = "PlatformError";
56
+ this.code = code;
57
+ }
58
+ }
59
+ export class ChannelTimeoutError extends PluginSdkError {
60
+ method;
61
+ timeoutMs;
62
+ constructor(method, timeoutMs) {
63
+ super(`Channel request "${method}" timed out after ${timeoutMs}ms`);
64
+ this.name = "ChannelTimeoutError";
65
+ this.method = method;
66
+ this.timeoutMs = timeoutMs;
67
+ }
68
+ }
69
+ export class ProtocolMismatchError extends PluginSdkError {
70
+ expectedMethod;
71
+ receivedMethod;
72
+ constructor(expectedMethod, receivedMethod) {
73
+ super(`Platform channel replied with "${receivedMethod}" to a "${expectedMethod}" request; rebuild the plugin against this Temps version`);
74
+ this.name = "ProtocolMismatchError";
75
+ this.expectedMethod = expectedMethod;
76
+ this.receivedMethod = receivedMethod;
77
+ }
78
+ }
79
+ export class ActorTokenRequiredError extends PluginSdkError {
80
+ constructor() {
81
+ super("This request has no platform actor token; declare an API capability and call the platform only for an authenticated caller");
82
+ this.name = "ActorTokenRequiredError";
83
+ }
84
+ }
85
+ export class CallBodyTooLargeError extends PluginSdkError {
86
+ actualBytes;
87
+ maximumBytes;
88
+ constructor(actualBytes, maximumBytes) {
89
+ super(`Platform API call body is ${actualBytes} bytes, exceeding the ${maximumBytes}-byte channel limit`);
90
+ this.name = "CallBodyTooLargeError";
91
+ this.actualBytes = actualBytes;
92
+ this.maximumBytes = maximumBytes;
93
+ }
94
+ }
95
+ export class RequestBodyTooLargeError extends PluginSdkError {
96
+ actualBytes;
97
+ maximumBytes;
98
+ constructor(actualBytes, maximumBytes) {
99
+ super(`Plugin request body is ${actualBytes} bytes, exceeding the ${maximumBytes}-byte runtime limit`);
100
+ this.name = "RequestBodyTooLargeError";
101
+ this.actualBytes = actualBytes;
102
+ this.maximumBytes = maximumBytes;
103
+ }
104
+ }
105
+ export class ResponseBodyTooLargeError extends PluginSdkError {
106
+ actualBytes;
107
+ maximumBytes;
108
+ constructor(actualBytes, maximumBytes) {
109
+ super(`Plugin response body is ${actualBytes} bytes, exceeding the ${maximumBytes}-byte runtime limit`);
110
+ this.name = "ResponseBodyTooLargeError";
111
+ this.actualBytes = actualBytes;
112
+ this.maximumBytes = maximumBytes;
113
+ }
114
+ }
115
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,6CAA6C;AAQ7C,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,SAAU,SAAQ,cAAc;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,cAAc;IACjC,IAAI,CAAS;IACb,MAAM,CAAS;IAE/B,YAAY,IAAY,EAAE,MAAc;QACtC,KAAK,CAAC,iCAAiC,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,iBAAi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AI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IAC3C,WAAW,CAAS;IACpB,YAAY,CAAS;IAErC,YAAY,WAAmB,EAAE,YAAoB;QACnD,KAAK,CACH,2BAA2B,WAAW,yBAAyB,YAAY,qBAAqB,CACjG,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ export { runPlugin, parsePluginArgs } from "./runtime.js";
2
+ export { ManifestBuilder, createManifest } from "./manifest-builder.js";
3
+ export { PluginContext } from "./context.js";
4
+ export { TempsClient } from "./client.js";
5
+ export { PlatformApi } from "./api.js";
6
+ export type { PlatformApiRequestOptions, PlatformApiResponse, } from "./api.js";
7
+ export { AuthenticatedCaller, extractAuthContext, secureSecretMatches, verifyProxyHeaders, } from "./auth.js";
8
+ export { encodeHandshakeMessage, emitHello, emitReady, parseLaunchConfigLine, readLaunchConfig, HEADER_PREFIX, HEADER_PLUGIN_NAME, HEADER_USER_ID, HEADER_USER_EMAIL, HEADER_USER_ROLE, HEADER_USER_PERMISSIONS, HEADER_REQUEST_ID, HEADER_AUTH_SIGNATURE, HEADER_ACTOR_TOKEN, PLUGIN_CHANNEL_PATH, PLUGIN_EVENTS_PATH, } from "./protocol.js";
9
+ export { createUiHandler, createEmbeddedUiHandler } from "./ui.js";
10
+ export type { EmbeddedFile, EmbeddedAssets } from "./ui.js";
11
+ export { PluginSdkError, ArgsError, SocketBindError, HandshakeError, InitializationError, ChannelClosedError, PlatformError, ChannelTimeoutError, ProtocolMismatchError, ActorTokenRequiredError, CallBodyTooLargeError, RequestBodyTooLargeError, ResponseBodyTooLargeError, } from "./errors.js";
12
+ export { EXTERNAL_PLUGIN_PROTOCOL_VERSION, MAX_CALL_BODY_BYTES, MAX_PLUGIN_REQUEST_BODY_BYTES, MAX_PLUGIN_RESPONSE_BODY_BYTES, } from "./types.js";
13
+ export type { TempsPlugin, RequestHandler, PluginManifest, PluginCapability, NavEntry, NavSection, UiManifest, UiRoute, HandshakeMessage, PluginHelloMessage, PluginReadyMessage, PluginLaunchConfig, ChannelMessage, ChannelRequest, ChannelResponse, ChannelEvent, ChannelError, ChannelErrorCode, PlatformCallMap, PlatformCallRequest, PlatformCallResponse, PlatformMethod, PluginEvent, ProjectInfo, EnvironmentInfo, DeploymentInfo, PluginRole, TempsUserContext, HttpMethod, PartContent, MultipartPart, CallBody, ApiCall, ApiCallResult, PluginArgs, } from "./types.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,YAAY,EACV,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACnE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EACL,cAAc,EACd,SAAS,EACT,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gCAAgC,EAChC,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,aAAa,EACb,QAAQ,EACR,OAAO,EACP,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
3
+ export { runPlugin, parsePluginArgs } from "./runtime.js";
4
+ export { ManifestBuilder, createManifest } from "./manifest-builder.js";
5
+ export { PluginContext } from "./context.js";
6
+ export { TempsClient } from "./client.js";
7
+ export { PlatformApi } from "./api.js";
8
+ export { AuthenticatedCaller, extractAuthContext, secureSecretMatches, verifyProxyHeaders, } from "./auth.js";
9
+ export { encodeHandshakeMessage, emitHello, emitReady, parseLaunchConfigLine, readLaunchConfig, HEADER_PREFIX, HEADER_PLUGIN_NAME, HEADER_USER_ID, HEADER_USER_EMAIL, HEADER_USER_ROLE, HEADER_USER_PERMISSIONS, HEADER_REQUEST_ID, HEADER_AUTH_SIGNATURE, HEADER_ACTOR_TOKEN, PLUGIN_CHANNEL_PATH, PLUGIN_EVENTS_PATH, } from "./protocol.js";
10
+ export { createUiHandler, createEmbeddedUiHandler } from "./ui.js";
11
+ export { PluginSdkError, ArgsError, SocketBindError, HandshakeError, InitializationError, ChannelClosedError, PlatformError, ChannelTimeoutError, ProtocolMismatchError, ActorTokenRequiredError, CallBodyTooLargeError, RequestBodyTooLargeError, ResponseBodyTooLargeError, } from "./errors.js";
12
+ export { EXTERNAL_PLUGIN_PROTOCOL_VERSION, MAX_CALL_BODY_BYTES, MAX_PLUGIN_REQUEST_BODY_BYTES, MAX_PLUGIN_RESPONSE_BODY_BYTES, } from "./types.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,6CAA6C;AAE7C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,EACL,cAAc,EACd,SAAS,EACT,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gCAAgC,EAChC,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Builder pattern for constructing PluginManifest instances.
3
+ *
4
+ * Mirrors the Rust `PluginManifest::builder()` pattern.
5
+ */
6
+ import type { NavEntry, NavSection, PluginCapability, PluginManifest, UiManifest } from "./types.js";
7
+ export declare class ManifestBuilder {
8
+ private _name;
9
+ private _version;
10
+ private _displayName?;
11
+ private _description?;
12
+ private _nav;
13
+ private _ui?;
14
+ private _requiresDb;
15
+ private _requiresHostDataAccess;
16
+ private _healthPath;
17
+ private _hideHeader;
18
+ private _publicPaths;
19
+ private _capabilities;
20
+ private _events;
21
+ constructor(name: string, version: string);
22
+ displayName(name: string): this;
23
+ description(desc: string): this;
24
+ nav(entry: NavEntry): this;
25
+ /**
26
+ * Add a navigation entry using shorthand parameters.
27
+ */
28
+ addNav(label: string, icon: string, path: string, options?: {
29
+ section?: NavSection;
30
+ order?: number;
31
+ }): this;
32
+ ui(manifest: UiManifest): this;
33
+ requiresDb(requires: boolean): this;
34
+ requiresHostDataAccess(requires: boolean): this;
35
+ healthPath(path: string): this;
36
+ hideHeader(hide?: boolean): this;
37
+ publicPath(path: string): this;
38
+ capability(capability: PluginCapability): this;
39
+ event(eventType: string): this;
40
+ events(eventTypes: string[]): this;
41
+ build(): PluginManifest;
42
+ }
43
+ /**
44
+ * Create a new manifest builder.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const manifest = createManifest("my-plugin", "0.1.0")
49
+ * .displayName("My Plugin")
50
+ * .description("Does amazing things")
51
+ * .addNav("Dashboard", "layout-dashboard", "/dashboard")
52
+ * .event("deployment.succeeded")
53
+ * .build();
54
+ * ```
55
+ */
56
+ export declare function createManifest(name: string, version: string): ManifestBuilder;
57
+ //# sourceMappingURL=manifest-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-builder.d.ts","sourceRoot":"","sources":["../src/manifest-builder.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,GAAG,CAAC,CAAa;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,OAAO,CAAgB;gBAEnB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAKzC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK/B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK/B,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAK1B;;OAEG;IACH,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACjD,IAAI;IAWP,EAAE,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI;IAK9B,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAKnC,sBAAsB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAK/C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK9B,UAAU,CAAC,IAAI,UAAO,GAAG,IAAI;IAK7B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK9B,UAAU,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAO9C,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAK9B,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI;IAKlC,KAAK,IAAI,cAAc;CAiBxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,eAAe,CAEjB"}
@@ -0,0 +1,118 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
3
+ export class ManifestBuilder {
4
+ _name;
5
+ _version;
6
+ _displayName;
7
+ _description;
8
+ _nav = [];
9
+ _ui;
10
+ _requiresDb = false;
11
+ _requiresHostDataAccess = false;
12
+ _healthPath = "/health";
13
+ _hideHeader = false;
14
+ _publicPaths = [];
15
+ _capabilities = [];
16
+ _events = [];
17
+ constructor(name, version) {
18
+ this._name = name;
19
+ this._version = version;
20
+ }
21
+ displayName(name) {
22
+ this._displayName = name;
23
+ return this;
24
+ }
25
+ description(desc) {
26
+ this._description = desc;
27
+ return this;
28
+ }
29
+ nav(entry) {
30
+ this._nav.push(entry);
31
+ return this;
32
+ }
33
+ /**
34
+ * Add a navigation entry using shorthand parameters.
35
+ */
36
+ addNav(label, icon, path, options) {
37
+ this._nav.push({
38
+ label,
39
+ icon,
40
+ path,
41
+ section: options?.section ?? "platform",
42
+ order: options?.order ?? 50,
43
+ });
44
+ return this;
45
+ }
46
+ ui(manifest) {
47
+ this._ui = manifest;
48
+ return this;
49
+ }
50
+ requiresDb(requires) {
51
+ this._requiresDb = requires;
52
+ return this;
53
+ }
54
+ requiresHostDataAccess(requires) {
55
+ this._requiresHostDataAccess = requires;
56
+ return this;
57
+ }
58
+ healthPath(path) {
59
+ this._healthPath = path;
60
+ return this;
61
+ }
62
+ hideHeader(hide = true) {
63
+ this._hideHeader = hide;
64
+ return this;
65
+ }
66
+ publicPath(path) {
67
+ this._publicPaths.push(path);
68
+ return this;
69
+ }
70
+ capability(capability) {
71
+ if (!this._capabilities.includes(capability)) {
72
+ this._capabilities.push(capability);
73
+ }
74
+ return this;
75
+ }
76
+ event(eventType) {
77
+ this._events.push(eventType);
78
+ return this;
79
+ }
80
+ events(eventTypes) {
81
+ this._events.push(...eventTypes);
82
+ return this;
83
+ }
84
+ build() {
85
+ return {
86
+ name: this._name,
87
+ version: this._version,
88
+ display_name: this._displayName,
89
+ description: this._description,
90
+ nav: this._nav,
91
+ ui: this._ui,
92
+ requires_db: this._requiresDb,
93
+ requires_host_data_access: this._requiresHostDataAccess,
94
+ health_path: this._healthPath,
95
+ hide_header: this._hideHeader,
96
+ public_paths: this._publicPaths,
97
+ capabilities: this._capabilities,
98
+ events: this._events,
99
+ };
100
+ }
101
+ }
102
+ /**
103
+ * Create a new manifest builder.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * const manifest = createManifest("my-plugin", "0.1.0")
108
+ * .displayName("My Plugin")
109
+ * .description("Does amazing things")
110
+ * .addNav("Dashboard", "layout-dashboard", "/dashboard")
111
+ * .event("deployment.succeeded")
112
+ * .build();
113
+ * ```
114
+ */
115
+ export function createManifest(name, version) {
116
+ return new ManifestBuilder(name, version);
117
+ }
118
+ //# sourceMappingURL=manifest-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-builder.js","sourceRoot":"","sources":["../src/manifest-builder.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,6CAA6C;AAgB7C,MAAM,OAAO,eAAe;IAClB,KAAK,CAAS;IACd,QAAQ,CAAS;IACjB,YAAY,CAAU;IACtB,YAAY,CAAU;IACtB,IAAI,GAAe,EAAE,CAAC;IACtB,GAAG,CAAc;IACjB,WAAW,GAAG,KAAK,CAAC;IACpB,uBAAuB,GAAG,KAAK,CAAC;IAChC,WAAW,GAAG,SAAS,CAAC;IACxB,WAAW,GAAG,KAAK,CAAC;IACpB,YAAY,GAAa,EAAE,CAAC;IAC5B,aAAa,GAAuB,EAAE,CAAC;IACvC,OAAO,GAAa,EAAE,CAAC;IAE/B,YAAY,IAAY,EAAE,OAAe;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,KAAe;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,MAAM,CACJ,KAAa,EACb,IAAY,EACZ,IAAY,EACZ,OAAkD;QAElD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACb,KAAK;YACL,IAAI;YACJ,IAAI;YACJ,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,UAAU;YACvC,KAAK,EAAE,OA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KAAK;YAChB,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,WAAW,EAAE,IAAI,CAAC,YAAY;YAC9B,GAAG,EAAE,IAAI,CAAC,IAAI;YACd,EAAE,EAAE,IAAI,CAAC,GAAG;YACZ,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,yBAAyB,EAAE,IAAI,CAAC,uBAAuB;YACvD,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,MAAM,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,OAAe;IAEf,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { HandshakeMessage, PluginLaunchConfig, PluginManifest } from "./types.js";
2
+ export declare const HEADER_PREFIX = "x-temps-";
3
+ export declare const HEADER_PLUGIN_NAME = "x-temps-plugin";
4
+ export declare const HEADER_USER_ID = "x-temps-user-id";
5
+ export declare const HEADER_USER_EMAIL = "x-temps-user-email";
6
+ export declare const HEADER_USER_ROLE = "x-temps-user-role";
7
+ export declare const HEADER_USER_PERMISSIONS = "x-temps-user-permissions";
8
+ export declare const HEADER_REQUEST_ID = "x-temps-request-id";
9
+ export declare const HEADER_AUTH_SIGNATURE = "x-temps-auth-signature";
10
+ export declare const HEADER_ACTOR_TOKEN = "x-temps-actor-token";
11
+ export declare const PLUGIN_CHANNEL_PATH = "/_temps/channel";
12
+ export declare const PLUGIN_EVENTS_PATH = "/_events";
13
+ export declare function encodeHandshakeMessage(message: HandshakeMessage): string;
14
+ export declare function writeHandshakeMessage(message: HandshakeMessage): void;
15
+ export declare function emitHello(manifest: PluginManifest): void;
16
+ export declare function emitReady(options: {
17
+ hasUi: boolean;
18
+ openapi?: Record<string, unknown>;
19
+ }): void;
20
+ export declare function parseLaunchConfigLine(line: string, manifest: PluginManifest): PluginLaunchConfig;
21
+ export declare function readLaunchConfig(manifest: PluginManifest, input?: NodeJS.ReadStream): Promise<PluginLaunchConfig>;
22
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACf,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AACpD,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAClE,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AAExD,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAE7C,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAExE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAErE;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAMxD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,GAAG,IAAI,CAQP;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,cAAc,GACvB,kBAAkB,CAgDpB;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,cAAc,EACxB,KAAK,GAAE,MAAM,CAAC,UAA0B,GACvC,OAAO,CAAC,kBAAkB,CAAC,CAG7B"}
@@ -0,0 +1,120 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
3
+ import { EXTERNAL_PLUGIN_PROTOCOL_VERSION } from "./types.js";
4
+ import { HandshakeError } from "./errors.js";
5
+ export const HEADER_PREFIX = "x-temps-";
6
+ export const HEADER_PLUGIN_NAME = "x-temps-plugin";
7
+ export const HEADER_USER_ID = "x-temps-user-id";
8
+ export const HEADER_USER_EMAIL = "x-temps-user-email";
9
+ export const HEADER_USER_ROLE = "x-temps-user-role";
10
+ export const HEADER_USER_PERMISSIONS = "x-temps-user-permissions";
11
+ export const HEADER_REQUEST_ID = "x-temps-request-id";
12
+ export const HEADER_AUTH_SIGNATURE = "x-temps-auth-signature";
13
+ export const HEADER_ACTOR_TOKEN = "x-temps-actor-token";
14
+ export const PLUGIN_CHANNEL_PATH = "/_temps/channel";
15
+ export const PLUGIN_EVENTS_PATH = "/_events";
16
+ export function encodeHandshakeMessage(message) {
17
+ return `${JSON.stringify(message)}\n`;
18
+ }
19
+ export function writeHandshakeMessage(message) {
20
+ process.stdout.write(encodeHandshakeMessage(message));
21
+ }
22
+ export function emitHello(manifest) {
23
+ writeHandshakeMessage({
24
+ type: "hello",
25
+ protocol_version: EXTERNAL_PLUGIN_PROTOCOL_VERSION,
26
+ manifest,
27
+ });
28
+ }
29
+ export function emitReady(options) {
30
+ writeHandshakeMessage({
31
+ type: "ready",
32
+ ready: true,
33
+ has_ui: options.hasUi,
34
+ protocol_version: EXTERNAL_PLUGIN_PROTOCOL_VERSION,
35
+ ...(options.openapi === undefined ? {} : { openapi: options.openapi }),
36
+ });
37
+ }
38
+ export function parseLaunchConfigLine(line, manifest) {
39
+ let value;
40
+ try {
41
+ value = JSON.parse(line);
42
+ }
43
+ catch (error) {
44
+ throw new HandshakeError(manifest.name, `Temps sent invalid launch configuration JSON: ${errorMessage(error)}`);
45
+ }
46
+ if (!isRecord(value)) {
47
+ throw new HandshakeError(manifest.name, "Temps sent a non-object launch configuration");
48
+ }
49
+ const protocolVersion = value.protocol_version;
50
+ const authSecret = value.auth_secret;
51
+ const databaseUrl = optionalString(value.database_url);
52
+ const hostDataDir = optionalString(value.host_data_dir);
53
+ if (protocolVersion !== EXTERNAL_PLUGIN_PROTOCOL_VERSION) {
54
+ throw new HandshakeError(manifest.name, `Temps sent external-plugin protocol ${String(protocolVersion)}, but this SDK requires ${EXTERNAL_PLUGIN_PROTOCOL_VERSION}`);
55
+ }
56
+ if (typeof authSecret !== "string" || authSecret.trim() === "") {
57
+ throw new HandshakeError(manifest.name, "Temps supplied an empty request-assertion secret");
58
+ }
59
+ if (databaseUrl === undefined || hostDataDir === undefined) {
60
+ throw new HandshakeError(manifest.name, "Temps sent invalid host path fields in launch configuration");
61
+ }
62
+ if (manifest.requires_db !== (databaseUrl !== null) ||
63
+ manifest.requires_host_data_access !== (hostDataDir !== null)) {
64
+ throw new HandshakeError(manifest.name, "Temps launch configuration does not match the manifest's declared host access requirements");
65
+ }
66
+ return {
67
+ protocol_version: protocolVersion,
68
+ auth_secret: authSecret,
69
+ database_url: databaseUrl,
70
+ host_data_dir: hostDataDir,
71
+ };
72
+ }
73
+ export async function readLaunchConfig(manifest, input = process.stdin) {
74
+ const line = await readOneLine(input, manifest.name);
75
+ return parseLaunchConfigLine(line, manifest);
76
+ }
77
+ function readOneLine(input, pluginName) {
78
+ return new Promise((resolve, reject) => {
79
+ let buffer = "";
80
+ const cleanup = () => {
81
+ input.off("data", onData);
82
+ input.off("end", onEnd);
83
+ input.off("error", onError);
84
+ input.pause();
85
+ };
86
+ const finish = (line) => {
87
+ cleanup();
88
+ resolve(line);
89
+ };
90
+ const onData = (chunk) => {
91
+ buffer += chunk.toString();
92
+ const newline = buffer.indexOf("\n");
93
+ if (newline >= 0)
94
+ finish(buffer.slice(0, newline));
95
+ };
96
+ const onEnd = () => {
97
+ cleanup();
98
+ reject(new HandshakeError(pluginName, "Temps closed stdin before sending typed launch configuration; the plugin and Temps likely use incompatible SDK versions"));
99
+ };
100
+ const onError = (error) => {
101
+ cleanup();
102
+ reject(new HandshakeError(pluginName, `Failed to read typed launch configuration: ${error.message}`));
103
+ };
104
+ input.setEncoding("utf8");
105
+ input.on("data", onData);
106
+ input.once("end", onEnd);
107
+ input.once("error", onError);
108
+ input.resume();
109
+ });
110
+ }
111
+ function optionalString(value) {
112
+ return value === null || typeof value === "string" ? value : undefined;
113
+ }
114
+ function isRecord(value) {
115
+ return typeof value === "object" && value !== null && !Array.isArray(value);
116
+ }
117
+ function errorMessage(error) {
118
+ return error instanceof Error ? error.message : String(error);
119
+ }
120
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,6CAA6C;AAO7C,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AACxC,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAChD,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AACpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AACtD,MAAM,CAAC,MAAM,qBAAqB,GAA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;QACF,MAAM,OAAO,GAAG,CAAC,KAAY,EAAE,EAAE;YAC/B,OAAO,EAAE,CAAC;YACV,MAAM,CACJ,IAAI,cAAc,CAChB,UAAU,EACV,8CAA8C,KAAK,CAAC,OAAO,EAAE,CAC9D,CACF,CAAC;QACJ,CAAC,CAAC;QAEF,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC1B,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7B,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type PluginArgs, type TempsPlugin } from "./types.js";
2
+ /** Run a TypeScript Temps plugin under Bun or as a Bun-compiled executable. */
3
+ export declare function runPlugin(plugin: TempsPlugin): Promise<void>;
4
+ export declare function parsePluginArgs(argv: string[]): PluginArgs;
5
+ /** @internal Read a plugin request without allowing unbounded process memory growth. */
6
+ export declare function readRequestBody(request: Request, maximumBytes?: number): Promise<Buffer>;
7
+ /** @internal Bounded response collector used by the Node-compatible bridge. */
8
+ export declare class ResponseBodyAccumulator {
9
+ #private;
10
+ constructor(maximumBytes?: number);
11
+ append(value: string | Buffer): void;
12
+ toBuffer(): Buffer;
13
+ }
14
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AA0BA,OAAO,EAGL,KAAK,UAAU,EAGf,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAKpB,+EAA+E;AAC/E,wBAAsB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA+LlE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA4B1D;AAyND,wFAAwF;AACxF,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,EAChB,YAAY,SAAgC,GAC3C,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,+EAA+E;AAC/E,qBAAa,uBAAuB;;gBAKtB,YAAY,SAAiC;IAIzD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAUpC,QAAQ,IAAI,MAAM;CAGnB"}