@stigmer/sdk 3.0.7 → 3.0.8-dev.20260612062921
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/gen/workflowinstance.d.ts +4 -1
- package/gen/workflowinstance.d.ts.map +1 -1
- package/gen/workflowinstance.js +9 -0
- package/gen/workflowinstance.js.map +1 -1
- package/node.d.ts +24 -0
- package/node.d.ts.map +1 -1
- package/node.js +69 -0
- package/node.js.map +1 -1
- package/node.test.d.ts +2 -0
- package/node.test.d.ts.map +1 -0
- package/node.test.js +35 -0
- package/node.test.js.map +1 -0
- package/package.json +2 -2
- package/src/gen/workflowinstance.ts +10 -2
- package/src/node.test.ts +38 -0
- package/src/node.ts +76 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ResourceRef } from "./types";
|
|
2
2
|
import { type Transport } from "@connectrpc/connect";
|
|
3
3
|
import { type WorkflowInstance } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/api_pb";
|
|
4
|
-
import { type GetWorkflowInstancesByWorkflowRequest, type WorkflowInstanceList } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/io_pb";
|
|
4
|
+
import { type UpdateExecutionVisibilityInput, type GetWorkflowInstancesByWorkflowRequest, type WorkflowInstanceList } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/io_pb";
|
|
5
|
+
import { WorkflowExecutionVisibility } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/spec_pb";
|
|
5
6
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
6
7
|
import { type UpdateVisibilityInput } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
7
8
|
/** Provides operations on workflowinstance resources. */
|
|
@@ -13,6 +14,7 @@ export declare class WorkflowInstanceClient {
|
|
|
13
14
|
create(input: WorkflowInstanceInput): Promise<WorkflowInstance>;
|
|
14
15
|
update(input: WorkflowInstanceInput): Promise<WorkflowInstance>;
|
|
15
16
|
updateVisibility(input: UpdateVisibilityInput): Promise<WorkflowInstance>;
|
|
17
|
+
updateExecutionVisibility(input: UpdateExecutionVisibilityInput): Promise<WorkflowInstance>;
|
|
16
18
|
delete(id: string): Promise<WorkflowInstance>;
|
|
17
19
|
get(id: string): Promise<WorkflowInstance>;
|
|
18
20
|
getByWorkflow(input: GetWorkflowInstancesByWorkflowRequest): Promise<WorkflowInstanceList>;
|
|
@@ -28,5 +30,6 @@ export interface WorkflowInstanceInput {
|
|
|
28
30
|
workflowId?: string;
|
|
29
31
|
description?: string;
|
|
30
32
|
environmentRefs?: ResourceRef[];
|
|
33
|
+
executionVisibility?: WorkflowExecutionVisibility;
|
|
31
34
|
}
|
|
32
35
|
//# sourceMappingURL=workflowinstance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflowinstance.d.ts","sourceRoot":"","sources":["../../src/gen/workflowinstance.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,+DAA+D,CAAC;AAE9H,OAAO,
|
|
1
|
+
{"version":3,"file":"workflowinstance.d.ts","sourceRoot":"","sources":["../../src/gen/workflowinstance.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,+DAA+D,CAAC;AAE9H,OAAO,EAA2I,KAAK,8BAA8B,EAAE,KAAK,qCAAqC,EAAE,KAAK,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AAEnU,OAAO,EAA8B,2BAA2B,EAAE,MAAM,gEAAgE,CAAC;AAEzI,OAAO,E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CAAC,EAAE,WAAW,EAAE,CAAC;IAChC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;CACnD"}
|
package/gen/workflowinstance.js
CHANGED
|
@@ -51,6 +51,14 @@ export class WorkflowInstanceClient {
|
|
|
51
51
|
throw wrapError(e);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
async updateExecutionVisibility(input) {
|
|
55
|
+
try {
|
|
56
|
+
return await this.command.updateExecutionVisibility(input);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
throw wrapError(e);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
54
62
|
async delete(id) {
|
|
55
63
|
try {
|
|
56
64
|
return await this.command.delete(create(WorkflowInstanceIdSchema, { value: id }));
|
|
@@ -100,6 +108,7 @@ function buildWorkflowInstanceProto(input) {
|
|
|
100
108
|
workflowId: input.workflowId,
|
|
101
109
|
description: input.description,
|
|
102
110
|
environmentRefs,
|
|
111
|
+
executionVisibility: input.executionVisibility,
|
|
103
112
|
})),
|
|
104
113
|
});
|
|
105
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflowinstance.js","sourceRoot":"","sources":["../../src/gen/workflowinstance.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAA+B,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAyB,MAAM,+DAA+D,CAAC;AAC9H,OAAO,EAAE,iCAAiC,EAAE,MAAM,mEAAmE,CAAC;AACtH,OAAO,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"workflowinstance.js","sourceRoot":"","sources":["../../src/gen/workflowinstance.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,OAAO,EAAE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AC,IAAI;YAChB,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACvC,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;YAC7C,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;SAC1D,CAAC;QACF,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,EAAE,cAAc,CAAC;YACrE,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,eAAe;YACf,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;SAC/C,CAAC,CAAC;KACJ,CAAqB,CAAC;AACzB,CAAC"}
|
package/node.d.ts
CHANGED
|
@@ -50,4 +50,28 @@ export declare function createNodeTransport(config: NodeClientConfig): Transport
|
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
export declare function createNodeClient(config: NodeClientConfig): Stigmer;
|
|
53
|
+
/**
|
|
54
|
+
* Normalize a user-supplied gRPC endpoint into a `baseUrl` for
|
|
55
|
+
* {@link createNodeTransport} / {@link createNodeClient}.
|
|
56
|
+
*
|
|
57
|
+
* Stigmer backends are configured with a bare `host:port` (e.g.
|
|
58
|
+
* `localhost:7234`) or a full URL, but the Connect transport requires a URL
|
|
59
|
+
* with a scheme. This helper mirrors the TLS decision of the Go server's
|
|
60
|
+
* endpoint rule — loopback is plaintext, an explicit `:443` is TLS, any other
|
|
61
|
+
* host without a port gets `:443` + TLS — and emits the resulting URL.
|
|
62
|
+
*
|
|
63
|
+
* It deliberately reproduces the Go rule's quirk of deriving TLS from the
|
|
64
|
+
* *port*, not the input scheme (so `https://host:8080` resolves to `http://`),
|
|
65
|
+
* so that the TS clients dial exactly where the Go MCP server and CLI do today.
|
|
66
|
+
* The shape differs from Go's `(host:port, useTLS)` return because the TS
|
|
67
|
+
* transport is URL-based, not dial-based.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* normalizeEndpoint("localhost:7234") // "http://localhost:7234"
|
|
71
|
+
* normalizeEndpoint("api.stigmer.ai") // "https://api.stigmer.ai:443"
|
|
72
|
+
* normalizeEndpoint("api.stigmer.ai:443") // "https://api.stigmer.ai:443"
|
|
73
|
+
* normalizeEndpoint("http://internal:8080")// "http://internal:8080"
|
|
74
|
+
* normalizeEndpoint("https://internal:80") // "http://internal:80" (TLS from port, not scheme)
|
|
75
|
+
*/
|
|
76
|
+
export declare function normalizeEndpoint(raw: string): string;
|
|
53
77
|
//# sourceMappingURL=node.d.ts.map
|
package/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAOtD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,iDAAiD;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;CACzC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAgBvE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CASlE"}
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAOtD,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,iDAAiD;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;CACzC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAgBvE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CASlE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAyBrD"}
|
package/node.js
CHANGED
|
@@ -58,4 +58,73 @@ export function createNodeClient(config) {
|
|
|
58
58
|
customTransport: transport,
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Normalize a user-supplied gRPC endpoint into a `baseUrl` for
|
|
63
|
+
* {@link createNodeTransport} / {@link createNodeClient}.
|
|
64
|
+
*
|
|
65
|
+
* Stigmer backends are configured with a bare `host:port` (e.g.
|
|
66
|
+
* `localhost:7234`) or a full URL, but the Connect transport requires a URL
|
|
67
|
+
* with a scheme. This helper mirrors the TLS decision of the Go server's
|
|
68
|
+
* endpoint rule — loopback is plaintext, an explicit `:443` is TLS, any other
|
|
69
|
+
* host without a port gets `:443` + TLS — and emits the resulting URL.
|
|
70
|
+
*
|
|
71
|
+
* It deliberately reproduces the Go rule's quirk of deriving TLS from the
|
|
72
|
+
* *port*, not the input scheme (so `https://host:8080` resolves to `http://`),
|
|
73
|
+
* so that the TS clients dial exactly where the Go MCP server and CLI do today.
|
|
74
|
+
* The shape differs from Go's `(host:port, useTLS)` return because the TS
|
|
75
|
+
* transport is URL-based, not dial-based.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* normalizeEndpoint("localhost:7234") // "http://localhost:7234"
|
|
79
|
+
* normalizeEndpoint("api.stigmer.ai") // "https://api.stigmer.ai:443"
|
|
80
|
+
* normalizeEndpoint("api.stigmer.ai:443") // "https://api.stigmer.ai:443"
|
|
81
|
+
* normalizeEndpoint("http://internal:8080")// "http://internal:8080"
|
|
82
|
+
* normalizeEndpoint("https://internal:80") // "http://internal:80" (TLS from port, not scheme)
|
|
83
|
+
*/
|
|
84
|
+
export function normalizeEndpoint(raw) {
|
|
85
|
+
let endpoint = raw.trim();
|
|
86
|
+
if (endpoint === "") {
|
|
87
|
+
throw new Error("normalizeEndpoint: endpoint must not be empty");
|
|
88
|
+
}
|
|
89
|
+
// gRPC targets are host:port; the scheme (if any) is informational and is
|
|
90
|
+
// stripped so the TLS decision derives solely from the resolved port.
|
|
91
|
+
endpoint = endpoint.replace(/^https?:\/\//i, "").replace(/\/+$/, "");
|
|
92
|
+
if (endpoint === "") {
|
|
93
|
+
throw new Error("normalizeEndpoint: endpoint has no host");
|
|
94
|
+
}
|
|
95
|
+
const { host, port } = splitHostPort(endpoint);
|
|
96
|
+
if (port !== "") {
|
|
97
|
+
return `${port === "443" ? "https" : "http"}://${endpoint}`;
|
|
98
|
+
}
|
|
99
|
+
// No explicit port: loopback stays plaintext as-is; everything else is
|
|
100
|
+
// assumed to be a public TLS endpoint on :443.
|
|
101
|
+
if (isLoopbackHost(host)) {
|
|
102
|
+
return `http://${endpoint}`;
|
|
103
|
+
}
|
|
104
|
+
return `https://${endpoint}:443`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Split a `host:port` authority, tolerating bracketed IPv6 (`[::1]:443`) and
|
|
108
|
+
* bare IPv6 (`::1`, treated as host-only). Mirrors the parsing intent of Go's
|
|
109
|
+
* `net.SplitHostPort` for the cases the endpoint rule cares about.
|
|
110
|
+
*/
|
|
111
|
+
function splitHostPort(authority) {
|
|
112
|
+
if (authority.startsWith("[")) {
|
|
113
|
+
const close = authority.indexOf("]");
|
|
114
|
+
if (close === -1)
|
|
115
|
+
return { host: authority, port: "" };
|
|
116
|
+
const host = authority.slice(0, close + 1);
|
|
117
|
+
const rest = authority.slice(close + 1);
|
|
118
|
+
return rest.startsWith(":") ? { host, port: rest.slice(1) } : { host, port: "" };
|
|
119
|
+
}
|
|
120
|
+
const lastColon = authority.lastIndexOf(":");
|
|
121
|
+
// No colon, or multiple colons without brackets (a bare IPv6 literal) → no port.
|
|
122
|
+
if (lastColon === -1 || authority.indexOf(":") !== lastColon) {
|
|
123
|
+
return { host: authority, port: "" };
|
|
124
|
+
}
|
|
125
|
+
return { host: authority.slice(0, lastColon), port: authority.slice(lastColon + 1) };
|
|
126
|
+
}
|
|
127
|
+
function isLoopbackHost(host) {
|
|
128
|
+
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]";
|
|
129
|
+
}
|
|
61
130
|
//# sourceMappingURL=node.js.map
|
package/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAsB,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,qB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FAAiF;IACjF,IAAI,SAAS,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;QAC7D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AACvF,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,OAAO,CAAC;AAC5F,CAAC"}
|
package/node.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.test.d.ts","sourceRoot":"","sources":["../src/node.test.ts"],"names":[],"mappings":""}
|
package/node.test.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { normalizeEndpoint } from "./node";
|
|
3
|
+
describe("normalizeEndpoint", () => {
|
|
4
|
+
it.each([
|
|
5
|
+
// Loopback hosts stay plaintext (the local daemon default).
|
|
6
|
+
["localhost:7234", "http://localhost:7234"],
|
|
7
|
+
["127.0.0.1:7234", "http://127.0.0.1:7234"],
|
|
8
|
+
["[::1]:7234", "http://[::1]:7234"],
|
|
9
|
+
// Explicit :443 is TLS; any other explicit port is plaintext.
|
|
10
|
+
["api.stigmer.ai:443", "https://api.stigmer.ai:443"],
|
|
11
|
+
["internal:8080", "http://internal:8080"],
|
|
12
|
+
// No port on a public host → assume TLS on :443.
|
|
13
|
+
["api.stigmer.ai", "https://api.stigmer.ai:443"],
|
|
14
|
+
// Loopback without a port stays plaintext and is left as-is.
|
|
15
|
+
["localhost", "http://localhost"],
|
|
16
|
+
])("normalizes %s → %s", (input, expected) => {
|
|
17
|
+
expect(normalizeEndpoint(input)).toBe(expected);
|
|
18
|
+
});
|
|
19
|
+
it("strips a URL scheme and derives TLS from the port, not the scheme", () => {
|
|
20
|
+
// Mirrors the Go rule's quirk: the port is authoritative for TLS.
|
|
21
|
+
expect(normalizeEndpoint("https://api.stigmer.ai")).toBe("https://api.stigmer.ai:443");
|
|
22
|
+
expect(normalizeEndpoint("http://internal:8080")).toBe("http://internal:8080");
|
|
23
|
+
expect(normalizeEndpoint("https://internal:8080")).toBe("http://internal:8080");
|
|
24
|
+
});
|
|
25
|
+
it("trims whitespace and trailing slashes", () => {
|
|
26
|
+
expect(normalizeEndpoint(" api.stigmer.ai:443/ ")).toBe("https://api.stigmer.ai:443");
|
|
27
|
+
expect(normalizeEndpoint("https://api.stigmer.ai/")).toBe("https://api.stigmer.ai:443");
|
|
28
|
+
});
|
|
29
|
+
it("throws on empty input", () => {
|
|
30
|
+
expect(() => normalizeEndpoint("")).toThrow(/must not be empty/);
|
|
31
|
+
expect(() => normalizeEndpoint(" ")).toThrow(/must not be empty/);
|
|
32
|
+
expect(() => normalizeEndpoint("https://")).toThrow(/no host/);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=node.test.js.map
|
package/node.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.test.js","sourceRoot":"","sources":["../src/node.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,IAAI,CAAC;QACN,4DAA4D;QAC5D,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;QAC3C,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;QAC3C,CAAC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KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACpE,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stigmer/sdk",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8-dev.20260612062921",
|
|
4
4
|
"description": "Stigmer TypeScript SDK — typed API client for all Stigmer platform resources",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@bufbuild/protobuf": "^2.0.0",
|
|
42
42
|
"@connectrpc/connect-node": "^2.0.0",
|
|
43
|
-
"@stigmer/protos": "3.0.
|
|
43
|
+
"@stigmer/protos": "3.0.8-dev.20260612062921"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -7,9 +7,9 @@ import { create } from "@bufbuild/protobuf";
|
|
|
7
7
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
8
8
|
import { WorkflowInstanceSchema, type WorkflowInstance } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/api_pb";
|
|
9
9
|
import { WorkflowInstanceCommandController } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/command_pb";
|
|
10
|
-
import { WorkflowInstanceIdSchema, GetWorkflowInstancesByWorkflowRequestSchema, WorkflowInstanceListSchema, type GetWorkflowInstancesByWorkflowRequest, type WorkflowInstanceList } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/io_pb";
|
|
10
|
+
import { WorkflowInstanceIdSchema, UpdateExecutionVisibilityInputSchema, GetWorkflowInstancesByWorkflowRequestSchema, WorkflowInstanceListSchema, type UpdateExecutionVisibilityInput, type GetWorkflowInstancesByWorkflowRequest, type WorkflowInstanceList } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/io_pb";
|
|
11
11
|
import { WorkflowInstanceQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/query_pb";
|
|
12
|
-
import { WorkflowInstanceSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/spec_pb";
|
|
12
|
+
import { WorkflowInstanceSpecSchema, WorkflowExecutionVisibility } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/spec_pb";
|
|
13
13
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
14
14
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
15
15
|
import { ApiResourceReferenceSchema, type UpdateVisibilityInput } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
@@ -49,6 +49,12 @@ export class WorkflowInstanceClient {
|
|
|
49
49
|
} catch (e) { throw wrapError(e); }
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
async updateExecutionVisibility(input: UpdateExecutionVisibilityInput): Promise<WorkflowInstance> {
|
|
53
|
+
try {
|
|
54
|
+
return await this.command.updateExecutionVisibility(input);
|
|
55
|
+
} catch (e) { throw wrapError(e); }
|
|
56
|
+
}
|
|
57
|
+
|
|
52
58
|
async delete(id: string): Promise<WorkflowInstance> {
|
|
53
59
|
try {
|
|
54
60
|
return await this.command.delete(create(WorkflowInstanceIdSchema, { value: id }));
|
|
@@ -84,6 +90,7 @@ export interface WorkflowInstanceInput {
|
|
|
84
90
|
workflowId?: string;
|
|
85
91
|
description?: string;
|
|
86
92
|
environmentRefs?: ResourceRef[];
|
|
93
|
+
executionVisibility?: WorkflowExecutionVisibility;
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
function buildWorkflowInstanceProto(input: WorkflowInstanceInput): WorkflowInstance {
|
|
@@ -102,6 +109,7 @@ function buildWorkflowInstanceProto(input: WorkflowInstanceInput): WorkflowInsta
|
|
|
102
109
|
workflowId: input.workflowId,
|
|
103
110
|
description: input.description,
|
|
104
111
|
environmentRefs,
|
|
112
|
+
executionVisibility: input.executionVisibility,
|
|
105
113
|
})),
|
|
106
114
|
}) as WorkflowInstance;
|
|
107
115
|
}
|
package/src/node.test.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { normalizeEndpoint } from "./node";
|
|
3
|
+
|
|
4
|
+
describe("normalizeEndpoint", () => {
|
|
5
|
+
it.each([
|
|
6
|
+
// Loopback hosts stay plaintext (the local daemon default).
|
|
7
|
+
["localhost:7234", "http://localhost:7234"],
|
|
8
|
+
["127.0.0.1:7234", "http://127.0.0.1:7234"],
|
|
9
|
+
["[::1]:7234", "http://[::1]:7234"],
|
|
10
|
+
// Explicit :443 is TLS; any other explicit port is plaintext.
|
|
11
|
+
["api.stigmer.ai:443", "https://api.stigmer.ai:443"],
|
|
12
|
+
["internal:8080", "http://internal:8080"],
|
|
13
|
+
// No port on a public host → assume TLS on :443.
|
|
14
|
+
["api.stigmer.ai", "https://api.stigmer.ai:443"],
|
|
15
|
+
// Loopback without a port stays plaintext and is left as-is.
|
|
16
|
+
["localhost", "http://localhost"],
|
|
17
|
+
])("normalizes %s → %s", (input, expected) => {
|
|
18
|
+
expect(normalizeEndpoint(input)).toBe(expected);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("strips a URL scheme and derives TLS from the port, not the scheme", () => {
|
|
22
|
+
// Mirrors the Go rule's quirk: the port is authoritative for TLS.
|
|
23
|
+
expect(normalizeEndpoint("https://api.stigmer.ai")).toBe("https://api.stigmer.ai:443");
|
|
24
|
+
expect(normalizeEndpoint("http://internal:8080")).toBe("http://internal:8080");
|
|
25
|
+
expect(normalizeEndpoint("https://internal:8080")).toBe("http://internal:8080");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("trims whitespace and trailing slashes", () => {
|
|
29
|
+
expect(normalizeEndpoint(" api.stigmer.ai:443/ ")).toBe("https://api.stigmer.ai:443");
|
|
30
|
+
expect(normalizeEndpoint("https://api.stigmer.ai/")).toBe("https://api.stigmer.ai:443");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("throws on empty input", () => {
|
|
34
|
+
expect(() => normalizeEndpoint("")).toThrow(/must not be empty/);
|
|
35
|
+
expect(() => normalizeEndpoint(" ")).toThrow(/must not be empty/);
|
|
36
|
+
expect(() => normalizeEndpoint("https://")).toThrow(/no host/);
|
|
37
|
+
});
|
|
38
|
+
});
|
package/src/node.ts
CHANGED
|
@@ -93,3 +93,79 @@ export function createNodeClient(config: NodeClientConfig): Stigmer {
|
|
|
93
93
|
customTransport: transport,
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Normalize a user-supplied gRPC endpoint into a `baseUrl` for
|
|
99
|
+
* {@link createNodeTransport} / {@link createNodeClient}.
|
|
100
|
+
*
|
|
101
|
+
* Stigmer backends are configured with a bare `host:port` (e.g.
|
|
102
|
+
* `localhost:7234`) or a full URL, but the Connect transport requires a URL
|
|
103
|
+
* with a scheme. This helper mirrors the TLS decision of the Go server's
|
|
104
|
+
* endpoint rule — loopback is plaintext, an explicit `:443` is TLS, any other
|
|
105
|
+
* host without a port gets `:443` + TLS — and emits the resulting URL.
|
|
106
|
+
*
|
|
107
|
+
* It deliberately reproduces the Go rule's quirk of deriving TLS from the
|
|
108
|
+
* *port*, not the input scheme (so `https://host:8080` resolves to `http://`),
|
|
109
|
+
* so that the TS clients dial exactly where the Go MCP server and CLI do today.
|
|
110
|
+
* The shape differs from Go's `(host:port, useTLS)` return because the TS
|
|
111
|
+
* transport is URL-based, not dial-based.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* normalizeEndpoint("localhost:7234") // "http://localhost:7234"
|
|
115
|
+
* normalizeEndpoint("api.stigmer.ai") // "https://api.stigmer.ai:443"
|
|
116
|
+
* normalizeEndpoint("api.stigmer.ai:443") // "https://api.stigmer.ai:443"
|
|
117
|
+
* normalizeEndpoint("http://internal:8080")// "http://internal:8080"
|
|
118
|
+
* normalizeEndpoint("https://internal:80") // "http://internal:80" (TLS from port, not scheme)
|
|
119
|
+
*/
|
|
120
|
+
export function normalizeEndpoint(raw: string): string {
|
|
121
|
+
let endpoint = raw.trim();
|
|
122
|
+
if (endpoint === "") {
|
|
123
|
+
throw new Error("normalizeEndpoint: endpoint must not be empty");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// gRPC targets are host:port; the scheme (if any) is informational and is
|
|
127
|
+
// stripped so the TLS decision derives solely from the resolved port.
|
|
128
|
+
endpoint = endpoint.replace(/^https?:\/\//i, "").replace(/\/+$/, "");
|
|
129
|
+
if (endpoint === "") {
|
|
130
|
+
throw new Error("normalizeEndpoint: endpoint has no host");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const { host, port } = splitHostPort(endpoint);
|
|
134
|
+
|
|
135
|
+
if (port !== "") {
|
|
136
|
+
return `${port === "443" ? "https" : "http"}://${endpoint}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// No explicit port: loopback stays plaintext as-is; everything else is
|
|
140
|
+
// assumed to be a public TLS endpoint on :443.
|
|
141
|
+
if (isLoopbackHost(host)) {
|
|
142
|
+
return `http://${endpoint}`;
|
|
143
|
+
}
|
|
144
|
+
return `https://${endpoint}:443`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Split a `host:port` authority, tolerating bracketed IPv6 (`[::1]:443`) and
|
|
149
|
+
* bare IPv6 (`::1`, treated as host-only). Mirrors the parsing intent of Go's
|
|
150
|
+
* `net.SplitHostPort` for the cases the endpoint rule cares about.
|
|
151
|
+
*/
|
|
152
|
+
function splitHostPort(authority: string): { host: string; port: string } {
|
|
153
|
+
if (authority.startsWith("[")) {
|
|
154
|
+
const close = authority.indexOf("]");
|
|
155
|
+
if (close === -1) return { host: authority, port: "" };
|
|
156
|
+
const host = authority.slice(0, close + 1);
|
|
157
|
+
const rest = authority.slice(close + 1);
|
|
158
|
+
return rest.startsWith(":") ? { host, port: rest.slice(1) } : { host, port: "" };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const lastColon = authority.lastIndexOf(":");
|
|
162
|
+
// No colon, or multiple colons without brackets (a bare IPv6 literal) → no port.
|
|
163
|
+
if (lastColon === -1 || authority.indexOf(":") !== lastColon) {
|
|
164
|
+
return { host: authority, port: "" };
|
|
165
|
+
}
|
|
166
|
+
return { host: authority.slice(0, lastColon), port: authority.slice(lastColon + 1) };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function isLoopbackHost(host: string): boolean {
|
|
170
|
+
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]";
|
|
171
|
+
}
|