@stigmer/sdk 3.12.3 → 3.12.5
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/__tests__/billing.test.js +36 -0
- package/__tests__/billing.test.js.map +1 -1
- package/__tests__/mcpserver-connect.test.d.ts +2 -0
- package/__tests__/mcpserver-connect.test.d.ts.map +1 -0
- package/__tests__/mcpserver-connect.test.js +146 -0
- package/__tests__/mcpserver-connect.test.js.map +1 -0
- package/__tests__/skill.test.d.ts +2 -0
- package/__tests__/skill.test.d.ts.map +1 -0
- package/__tests__/skill.test.js +117 -0
- package/__tests__/skill.test.js.map +1 -0
- package/__tests__/update-input.test.d.ts +2 -0
- package/__tests__/update-input.test.d.ts.map +1 -0
- package/__tests__/update-input.test.js +169 -0
- package/__tests__/update-input.test.js.map +1 -0
- package/billing.d.ts +27 -0
- package/billing.d.ts.map +1 -1
- package/billing.js +26 -1
- package/billing.js.map +1 -1
- package/errors.d.ts +1 -1
- package/errors.d.ts.map +1 -1
- package/errors.js +1 -1
- package/errors.js.map +1 -1
- package/execution/__tests__/tool-view.fixtures.test.js +23 -4
- package/execution/__tests__/tool-view.fixtures.test.js.map +1 -1
- package/execution/tool-view.d.ts +32 -0
- package/execution/tool-view.d.ts.map +1 -1
- package/execution/tool-view.js +45 -0
- package/execution/tool-view.js.map +1 -1
- package/gen/agentexecution.d.ts +6 -0
- package/gen/agentexecution.d.ts.map +1 -1
- package/gen/agentexecution.js +9 -1
- package/gen/agentexecution.js.map +1 -1
- package/gen/client.d.ts +4 -4
- package/gen/client.d.ts.map +1 -1
- package/gen/client.js +1 -1
- package/gen/client.js.map +1 -1
- package/gen/errors.d.ts +7 -0
- package/gen/errors.d.ts.map +1 -1
- package/gen/errors.js +9 -0
- package/gen/errors.js.map +1 -1
- package/gen/identityaccount.d.ts +8 -0
- package/gen/identityaccount.d.ts.map +1 -1
- package/gen/identityaccount.js +11 -1
- package/gen/identityaccount.js.map +1 -1
- package/gen/mcpserver.d.ts +1 -0
- package/gen/mcpserver.d.ts.map +1 -1
- package/gen/mcpserver.js +8 -0
- package/gen/mcpserver.js.map +1 -1
- package/gen/oauthapp.d.ts +2 -1
- package/gen/oauthapp.d.ts.map +1 -1
- package/gen/oauthapp.js +1 -0
- package/gen/oauthapp.js.map +1 -1
- package/gen/organization.d.ts +5 -0
- package/gen/organization.d.ts.map +1 -1
- package/gen/organization.js +8 -1
- package/gen/organization.js.map +1 -1
- package/gen/platformclient.d.ts +1 -0
- package/gen/platformclient.d.ts.map +1 -1
- package/gen/platformclient.js +2 -0
- package/gen/platformclient.js.map +1 -1
- package/index.d.ts +6 -2
- package/index.d.ts.map +1 -1
- package/index.js +8 -2
- package/index.js.map +1 -1
- package/mcpserver-connect.d.ts +79 -0
- package/mcpserver-connect.d.ts.map +1 -0
- package/mcpserver-connect.js +114 -0
- package/mcpserver-connect.js.map +1 -0
- package/package.json +2 -2
- package/provider-standing.d.ts +19 -0
- package/provider-standing.d.ts.map +1 -0
- package/provider-standing.js +31 -0
- package/provider-standing.js.map +1 -0
- package/skill.d.ts +51 -0
- package/skill.d.ts.map +1 -0
- package/skill.js +102 -0
- package/skill.js.map +1 -0
- package/src/__tests__/billing.test.ts +44 -0
- package/src/__tests__/mcpserver-connect.test.ts +181 -0
- package/src/__tests__/skill.test.ts +150 -0
- package/src/__tests__/update-input.test.ts +219 -0
- package/src/billing.ts +44 -0
- package/src/errors.ts +1 -0
- package/src/execution/__tests__/tool-view.fixtures.test.ts +41 -4
- package/src/execution/tool-view.ts +52 -0
- package/src/gen/agentexecution.ts +17 -1
- package/src/gen/client.ts +4 -4
- package/src/gen/errors.ts +10 -0
- package/src/gen/identityaccount.ts +21 -1
- package/src/gen/mcpserver.ts +6 -0
- package/src/gen/oauthapp.ts +3 -1
- package/src/gen/organization.ts +15 -1
- package/src/gen/platformclient.ts +3 -0
- package/src/index.ts +22 -0
- package/src/mcpserver-connect.ts +159 -0
- package/src/provider-standing.ts +37 -0
- package/src/skill.ts +125 -0
- package/src/stigmer.ts +12 -0
- package/src/update-input.ts +168 -0
- package/stigmer.d.ts +10 -0
- package/stigmer.d.ts.map +1 -1
- package/stigmer.js +12 -0
- package/stigmer.js.map +1 -1
- package/update-input.d.ts +24 -0
- package/update-input.d.ts.map +1 -0
- package/update-input.js +126 -0
- package/update-input.js.map +1 -0
package/src/skill.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { create } from "@bufbuild/protobuf";
|
|
2
|
+
import { Code } from "@connectrpc/connect";
|
|
3
|
+
import type { Transport } from "@connectrpc/connect";
|
|
4
|
+
import type { Skill } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/api_pb";
|
|
5
|
+
import {
|
|
6
|
+
CreateSkillArtifactUploadUrlRequestSchema,
|
|
7
|
+
PushSkillRequestSchema,
|
|
8
|
+
type PushSkillRequest,
|
|
9
|
+
} from "@stigmer/protos/ai/stigmer/agentic/skill/v1/io_pb";
|
|
10
|
+
import { isUnimplemented, StigmerError } from "./gen/errors.js";
|
|
11
|
+
import { SkillClient } from "./gen/skill.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Largest artifact pushed inline in the gRPC request (#675). The server's
|
|
15
|
+
* transport cap is 10MB for the WHOLE message, so the artifact leaves 64KB
|
|
16
|
+
* of headroom for the request envelope (org, tag, provenance, framing).
|
|
17
|
+
* Mirrors the Go SDK's maxInlineArtifactBytes.
|
|
18
|
+
*/
|
|
19
|
+
export const MAX_INLINE_ARTIFACT_BYTES = 10 * 1024 * 1024 - 64 * 1024;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Skill client with transport-aware push routing (stigmer#675 / #701).
|
|
23
|
+
*
|
|
24
|
+
* The gRPC transport caps messages at 10MB while skills may be up to 100MB,
|
|
25
|
+
* so `push` routes by size: small artifacts travel inline in the request
|
|
26
|
+
* (one round trip, unchanged behavior), larger ones are staged over HTTP
|
|
27
|
+
* via `createArtifactUploadUrl` — a capability URL, so no auth header —
|
|
28
|
+
* and pushed by reference. Callers never see the mechanics: `push(req)`
|
|
29
|
+
* simply works for any valid skill size.
|
|
30
|
+
*
|
|
31
|
+
* Every other method is the generated client's, inherited unchanged.
|
|
32
|
+
*/
|
|
33
|
+
export class RoutedSkillClient extends SkillClient {
|
|
34
|
+
private readonly fetchImpl: typeof globalThis.fetch | undefined;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param fetchImpl - Custom `fetch` for the staging PUT. Must be the same
|
|
38
|
+
* implementation the transport uses where the global one is restricted
|
|
39
|
+
* (the Tauri CSP/CORS case the `Stigmer.fetch` property documents).
|
|
40
|
+
*/
|
|
41
|
+
constructor(transport: Transport, fetchImpl?: typeof globalThis.fetch) {
|
|
42
|
+
super(transport);
|
|
43
|
+
this.fetchImpl = fetchImpl;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Push a skill, routing the artifact by size (see the class comment).
|
|
48
|
+
*
|
|
49
|
+
* A request that already carries an `artifactUploadRef` is passed through
|
|
50
|
+
* untouched — the caller has done its own staging.
|
|
51
|
+
*/
|
|
52
|
+
override async push(input: PushSkillRequest): Promise<Skill> {
|
|
53
|
+
if (input.artifactUploadRef !== "" || input.artifact.length <= MAX_INLINE_ARTIFACT_BYTES) {
|
|
54
|
+
return super.push(input);
|
|
55
|
+
}
|
|
56
|
+
return this.pushViaUploadUrl(input);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Stage the artifact over HTTP and push by reference:
|
|
61
|
+
* createArtifactUploadUrl → PUT bytes → push(artifactUploadRef).
|
|
62
|
+
*/
|
|
63
|
+
private async pushViaUploadUrl(input: PushSkillRequest): Promise<Skill> {
|
|
64
|
+
let minted;
|
|
65
|
+
try {
|
|
66
|
+
minted = await super.createArtifactUploadUrl(
|
|
67
|
+
create(CreateSkillArtifactUploadUrlRequestSchema, {
|
|
68
|
+
org: input.org,
|
|
69
|
+
sizeBytes: BigInt(input.artifact.length),
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
if (isUnimplemented(err)) {
|
|
74
|
+
// Pre-transfer-lane server: without staging, an artifact this size
|
|
75
|
+
// physically cannot travel. Say so instead of surfacing the raw
|
|
76
|
+
// transport error (the failure mode #675 reported).
|
|
77
|
+
throw new StigmerError(
|
|
78
|
+
"unknown",
|
|
79
|
+
`skill artifact is ${input.artifact.length} bytes, above the ~10MB gRPC message cap, ` +
|
|
80
|
+
"and this server does not support the HTTP artifact transfer lane — " +
|
|
81
|
+
"upgrade stigmer-server to push skills of this size",
|
|
82
|
+
Code.Unimplemented,
|
|
83
|
+
{ cause: err },
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
await this.putArtifact(minted.url, input.artifact);
|
|
90
|
+
|
|
91
|
+
// Same request, artifact traveling by reference instead of by value.
|
|
92
|
+
const byRef = create(PushSkillRequestSchema, {
|
|
93
|
+
...input,
|
|
94
|
+
artifact: new Uint8Array(0),
|
|
95
|
+
artifactUploadRef: minted.artifactUploadRef,
|
|
96
|
+
});
|
|
97
|
+
return super.push(byRef);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* PUT the artifact ZIP to the staging URL. The URL is the credential
|
|
102
|
+
* (capability semantics — a pre-signed R2 URL on cloud, the server's own
|
|
103
|
+
* transfer lane on OSS), so no auth header is attached.
|
|
104
|
+
*/
|
|
105
|
+
private async putArtifact(url: string, artifact: Uint8Array): Promise<void> {
|
|
106
|
+
const doFetch = this.fetchImpl ?? globalThis.fetch;
|
|
107
|
+
const resp = await doFetch(url, {
|
|
108
|
+
method: "PUT",
|
|
109
|
+
// Both DOM and undici accept an ArrayBufferView body at runtime; the
|
|
110
|
+
// cast bridges TS 5.7's ArrayBufferLike generic, which BodyInit's
|
|
111
|
+
// typing predates. A Blob/Buffer wrapper would copy up to 100MB for
|
|
112
|
+
// nothing, and Buffer is Node-only while this client is isomorphic.
|
|
113
|
+
body: artifact as unknown as RequestInit["body"],
|
|
114
|
+
headers: { "content-type": "application/zip" },
|
|
115
|
+
});
|
|
116
|
+
if (!resp.ok) {
|
|
117
|
+
const detail = (await resp.text().catch(() => "")).slice(0, 512).trim();
|
|
118
|
+
throw new StigmerError(
|
|
119
|
+
"unknown",
|
|
120
|
+
`skill artifact upload rejected with HTTP ${resp.status}${detail === "" ? "" : `: ${detail}`}`,
|
|
121
|
+
Code.Unknown,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
package/src/stigmer.ts
CHANGED
|
@@ -5,7 +5,9 @@ import { GeneratedClient } from "./gen/client.js";
|
|
|
5
5
|
import { GitHubClient } from "./github.js";
|
|
6
6
|
import { ManifestClient } from "./manifest/index.js";
|
|
7
7
|
import { PlatformClient } from "./platform.js";
|
|
8
|
+
import { ProviderStandingClient } from "./provider-standing.js";
|
|
8
9
|
import { SearchClient } from "./search.js";
|
|
10
|
+
import { RoutedSkillClient } from "./skill.js";
|
|
9
11
|
import { createStigmerTransport } from "./transport.js";
|
|
10
12
|
import {
|
|
11
13
|
validateConfig,
|
|
@@ -78,10 +80,18 @@ export class Stigmer extends GeneratedClient {
|
|
|
78
80
|
readonly billing: BillingClient;
|
|
79
81
|
/** Managed Cursor accounts (platform operators only). */
|
|
80
82
|
readonly cursorAccounts: CursorAccountsClient;
|
|
83
|
+
/** Platform provider standing, read-only (platform operators only). */
|
|
84
|
+
readonly providerStanding: ProviderStandingClient;
|
|
81
85
|
readonly platform: PlatformClient;
|
|
82
86
|
readonly search: SearchClient;
|
|
83
87
|
readonly github: GitHubClient;
|
|
84
88
|
readonly manifest: ManifestClient;
|
|
89
|
+
/**
|
|
90
|
+
* Skill operations, with `push` routed by artifact size over the transfer
|
|
91
|
+
* lane (stigmer#675) — shadows the inherited generated client so
|
|
92
|
+
* `stigmer.skill.push` simply works for any valid skill size.
|
|
93
|
+
*/
|
|
94
|
+
override readonly skill: RoutedSkillClient;
|
|
85
95
|
|
|
86
96
|
private readonly _tokenProvider: TokenProvider;
|
|
87
97
|
|
|
@@ -101,10 +111,12 @@ export class Stigmer extends GeneratedClient {
|
|
|
101
111
|
this.activity = new ActivityClient(transport);
|
|
102
112
|
this.billing = new BillingClient(transport);
|
|
103
113
|
this.cursorAccounts = new CursorAccountsClient(transport);
|
|
114
|
+
this.providerStanding = new ProviderStandingClient(transport);
|
|
104
115
|
this.platform = new PlatformClient(transport);
|
|
105
116
|
this.search = new SearchClient(transport);
|
|
106
117
|
this.github = new GitHubClient(transport);
|
|
107
118
|
this.manifest = new ManifestClient(transport);
|
|
119
|
+
this.skill = new RoutedSkillClient(transport, config.fetch);
|
|
108
120
|
|
|
109
121
|
if (this.defaultExecutionTarget != null) {
|
|
110
122
|
this._applyExecutionTargetDefaults();
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Complete update-input mappers.
|
|
2
|
+
//
|
|
3
|
+
// The platform's update RPCs are FULL-SPEC REPLACEMENTS: the request spec
|
|
4
|
+
// wholesale overwrites the stored spec (both editions; only a small
|
|
5
|
+
// server-side preserve list of immutable identifiers survives). A client
|
|
6
|
+
// that sends only the fields it edits therefore silently WIPES every other
|
|
7
|
+
// mutable spec field — a data-loss bug class, not a single bug
|
|
8
|
+
// (stigmer/stigmer#293 Phase 1 surfaced it when `spec.preferences` set via
|
|
9
|
+
// CLI was dropped by a console profile save).
|
|
10
|
+
//
|
|
11
|
+
// These mappers are the structural fix: they convert a LOADED resource into
|
|
12
|
+
// a complete `*Input` for the generated update builders. Editors spread the
|
|
13
|
+
// mapper output and override only the fields they edit:
|
|
14
|
+
//
|
|
15
|
+
// await update({ ...toOrganizationUpdateInput(org), description: next });
|
|
16
|
+
//
|
|
17
|
+
// The `CompleteInput` mapped type removes optionality from every Input key,
|
|
18
|
+
// so when codegen adds a new Input field, compilation fails HERE — the one
|
|
19
|
+
// place a human must decide how the new field round-trips — instead of the
|
|
20
|
+
// field silently wiping in every subset-editing form.
|
|
21
|
+
//
|
|
22
|
+
// NESTED MESSAGE RULE: `CompleteInput` only sees TOP-LEVEL keys — a nested
|
|
23
|
+
// message (e.g. `preferences`) is one key whose object literal would keep
|
|
24
|
+
// compiling when codegen adds fields INSIDE it, recreating the wipe bug one
|
|
25
|
+
// level down. Every nested-message literal in this file must therefore be
|
|
26
|
+
// built by a dedicated `toXxxInput` helper whose return literal is itself
|
|
27
|
+
// typed `CompleteInput<XxxInput>`. Editors that override a nested message
|
|
28
|
+
// must spread the mapper's complete value and override only their fields:
|
|
29
|
+
//
|
|
30
|
+
// preferences: { ...mapped.preferences, standingContext: next }
|
|
31
|
+
|
|
32
|
+
import type { ApiResourceReference } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
33
|
+
import type { IdentityAccount } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
|
|
34
|
+
import type { IdentityAccountPreferences } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/spec_pb";
|
|
35
|
+
import type { Organization } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/api_pb";
|
|
36
|
+
import type { OrganizationPreferences } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/spec_pb";
|
|
37
|
+
import type {
|
|
38
|
+
IdentityAccountInput,
|
|
39
|
+
IdentityAccountPreferencesInput,
|
|
40
|
+
} from "./gen/identityaccount.js";
|
|
41
|
+
import type {
|
|
42
|
+
OrganizationInput,
|
|
43
|
+
OrganizationPreferencesInput,
|
|
44
|
+
} from "./gen/organization.js";
|
|
45
|
+
import type { ResourceRef } from "./gen/types.js";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Every key of `T`, required to be present. Optional keys keep their
|
|
49
|
+
* `| undefined` value type (explicit `undefined` is stripped by the proto
|
|
50
|
+
* builders), so a mapper cannot compile while omitting an Input field.
|
|
51
|
+
*
|
|
52
|
+
* Mapping over `keyof Required<T>` (instead of a homomorphic `-?` map)
|
|
53
|
+
* is deliberate: `-?` would also strip `undefined` from optional value
|
|
54
|
+
* types, forcing fake values for genuinely absent fields.
|
|
55
|
+
*/
|
|
56
|
+
type CompleteInput<T> = { [K in keyof Required<T>]: T[K] };
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Maps a loaded {@link Organization} to a complete {@link OrganizationInput}
|
|
60
|
+
* for `organization.update()`.
|
|
61
|
+
*
|
|
62
|
+
* Proto3 scalar defaults (empty string, `false`, enum `0`) are normalized to
|
|
63
|
+
* `undefined` — omitting them is wire-identical to sending the default, and
|
|
64
|
+
* it keeps the built proto in the builders' canonical shape.
|
|
65
|
+
*/
|
|
66
|
+
export function toOrganizationUpdateInput(
|
|
67
|
+
org: Organization,
|
|
68
|
+
): OrganizationInput {
|
|
69
|
+
const input: CompleteInput<OrganizationInput> = {
|
|
70
|
+
name: org.metadata?.name ?? "",
|
|
71
|
+
slug: org.metadata?.slug || undefined,
|
|
72
|
+
org: org.metadata?.org || org.metadata?.slug || "",
|
|
73
|
+
labels: nonEmptyLabels(org.metadata?.labels),
|
|
74
|
+
visibility: org.metadata?.visibility || undefined,
|
|
75
|
+
description: org.spec?.description || undefined,
|
|
76
|
+
logoUrl: org.spec?.logoUrl || undefined,
|
|
77
|
+
managementMode: org.spec?.managementMode || undefined,
|
|
78
|
+
identityProviderRef: toResourceRef(org.spec?.identityProviderRef),
|
|
79
|
+
externalOrgId: org.spec?.externalOrgId || undefined,
|
|
80
|
+
isPersonal: org.spec?.isPersonal || undefined,
|
|
81
|
+
preferences: org.spec?.preferences
|
|
82
|
+
? toOrganizationPreferencesInput(org.spec.preferences)
|
|
83
|
+
: undefined,
|
|
84
|
+
};
|
|
85
|
+
return input;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Maps loaded {@link OrganizationPreferences} to a complete
|
|
90
|
+
* {@link OrganizationPreferencesInput} (nested-message rule above).
|
|
91
|
+
*/
|
|
92
|
+
function toOrganizationPreferencesInput(
|
|
93
|
+
preferences: OrganizationPreferences,
|
|
94
|
+
): OrganizationPreferencesInput {
|
|
95
|
+
const input: CompleteInput<OrganizationPreferencesInput> = {
|
|
96
|
+
standingContext: preferences.standingContext || undefined,
|
|
97
|
+
};
|
|
98
|
+
return input;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Maps a loaded {@link IdentityAccount} to a complete
|
|
103
|
+
* {@link IdentityAccountInput} for `identityAccount.update()`.
|
|
104
|
+
*
|
|
105
|
+
* The generated builder never sets `metadata.id`; the update pipeline
|
|
106
|
+
* locates the resource by org + slug instead (and authorizes against the
|
|
107
|
+
* loaded resource's id), so carrying `org` and `slug` here is what makes
|
|
108
|
+
* the update addressable.
|
|
109
|
+
*/
|
|
110
|
+
export function toIdentityAccountUpdateInput(
|
|
111
|
+
account: IdentityAccount,
|
|
112
|
+
): IdentityAccountInput {
|
|
113
|
+
const input: CompleteInput<IdentityAccountInput> = {
|
|
114
|
+
name: account.metadata?.name ?? "",
|
|
115
|
+
slug: account.metadata?.slug || undefined,
|
|
116
|
+
org: account.metadata?.org ?? "",
|
|
117
|
+
labels: nonEmptyLabels(account.metadata?.labels),
|
|
118
|
+
visibility: account.metadata?.visibility || undefined,
|
|
119
|
+
idpId: account.spec?.idpId ?? "",
|
|
120
|
+
email: account.spec?.email || undefined,
|
|
121
|
+
firstName: account.spec?.firstName || undefined,
|
|
122
|
+
lastName: account.spec?.lastName || undefined,
|
|
123
|
+
pictureUrl: account.spec?.pictureUrl || undefined,
|
|
124
|
+
isMachineAccount: account.spec?.isMachineAccount || undefined,
|
|
125
|
+
provisioningMode: account.spec?.provisioningMode || undefined,
|
|
126
|
+
identityProviderRef: toResourceRef(account.spec?.identityProviderRef),
|
|
127
|
+
preferences: account.spec?.preferences
|
|
128
|
+
? toIdentityAccountPreferencesInput(account.spec.preferences)
|
|
129
|
+
: undefined,
|
|
130
|
+
};
|
|
131
|
+
return input;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Maps loaded {@link IdentityAccountPreferences} to a complete
|
|
136
|
+
* {@link IdentityAccountPreferencesInput} (nested-message rule above).
|
|
137
|
+
*/
|
|
138
|
+
function toIdentityAccountPreferencesInput(
|
|
139
|
+
preferences: IdentityAccountPreferences,
|
|
140
|
+
): IdentityAccountPreferencesInput {
|
|
141
|
+
const input: CompleteInput<IdentityAccountPreferencesInput> = {
|
|
142
|
+
standingContext: preferences.standingContext || undefined,
|
|
143
|
+
defaultHarness: preferences.defaultHarness || undefined,
|
|
144
|
+
defaultNativeModel: preferences.defaultNativeModel || undefined,
|
|
145
|
+
defaultCursorModel: preferences.defaultCursorModel || undefined,
|
|
146
|
+
};
|
|
147
|
+
return input;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function nonEmptyLabels(
|
|
151
|
+
labels: Record<string, string> | undefined,
|
|
152
|
+
): Record<string, string> | undefined {
|
|
153
|
+
return labels && Object.keys(labels).length > 0 ? labels : undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function toResourceRef(
|
|
157
|
+
ref: ApiResourceReference | undefined,
|
|
158
|
+
): ResourceRef | undefined {
|
|
159
|
+
// The builders treat a ref without org and slug as absent; mirror that so
|
|
160
|
+
// an empty message round-trips to "no reference".
|
|
161
|
+
if (!ref || (!ref.org && !ref.slug)) return undefined;
|
|
162
|
+
return {
|
|
163
|
+
org: ref.org,
|
|
164
|
+
slug: ref.slug,
|
|
165
|
+
...(ref.version && { version: ref.version }),
|
|
166
|
+
...(ref.kind && { kind: ref.kind }),
|
|
167
|
+
};
|
|
168
|
+
}
|
package/stigmer.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ import { GeneratedClient } from "./gen/client.js";
|
|
|
5
5
|
import { GitHubClient } from "./github.js";
|
|
6
6
|
import { ManifestClient } from "./manifest/index.js";
|
|
7
7
|
import { PlatformClient } from "./platform.js";
|
|
8
|
+
import { ProviderStandingClient } from "./provider-standing.js";
|
|
8
9
|
import { SearchClient } from "./search.js";
|
|
10
|
+
import { RoutedSkillClient } from "./skill.js";
|
|
9
11
|
import { type StigmerConfig } from "./config.js";
|
|
10
12
|
import { ExecutionTarget } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
11
13
|
/**
|
|
@@ -67,10 +69,18 @@ export declare class Stigmer extends GeneratedClient {
|
|
|
67
69
|
readonly billing: BillingClient;
|
|
68
70
|
/** Managed Cursor accounts (platform operators only). */
|
|
69
71
|
readonly cursorAccounts: CursorAccountsClient;
|
|
72
|
+
/** Platform provider standing, read-only (platform operators only). */
|
|
73
|
+
readonly providerStanding: ProviderStandingClient;
|
|
70
74
|
readonly platform: PlatformClient;
|
|
71
75
|
readonly search: SearchClient;
|
|
72
76
|
readonly github: GitHubClient;
|
|
73
77
|
readonly manifest: ManifestClient;
|
|
78
|
+
/**
|
|
79
|
+
* Skill operations, with `push` routed by artifact size over the transfer
|
|
80
|
+
* lane (stigmer#675) — shadows the inherited generated client so
|
|
81
|
+
* `stigmer.skill.push` simply works for any valid skill size.
|
|
82
|
+
*/
|
|
83
|
+
readonly skill: RoutedSkillClient;
|
|
74
84
|
private readonly _tokenProvider;
|
|
75
85
|
constructor(config: StigmerConfig);
|
|
76
86
|
/**
|
package/stigmer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stigmer.d.ts","sourceRoot":"","sources":["../src/stigmer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OA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,CAAC;IAC9C,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC;;;;OAIG;IACH,SAAkB,KAAK,EAAE,iBAAiB,CAAC;IAE3C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;gBAEnC,MAAM,EAAE,aAAa;IA4BjC;;;;;;;;;OASG;IACH,OAAO,CAAC,6BAA6B;IAoBrC;;;;;;;;;OASG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAGlD"}
|
package/stigmer.js
CHANGED
|
@@ -5,7 +5,9 @@ import { GeneratedClient } from "./gen/client.js";
|
|
|
5
5
|
import { GitHubClient } from "./github.js";
|
|
6
6
|
import { ManifestClient } from "./manifest/index.js";
|
|
7
7
|
import { PlatformClient } from "./platform.js";
|
|
8
|
+
import { ProviderStandingClient } from "./provider-standing.js";
|
|
8
9
|
import { SearchClient } from "./search.js";
|
|
10
|
+
import { RoutedSkillClient } from "./skill.js";
|
|
9
11
|
import { createStigmerTransport } from "./transport.js";
|
|
10
12
|
import { validateConfig, } from "./config.js";
|
|
11
13
|
import { ExecutionTarget } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
@@ -68,10 +70,18 @@ export class Stigmer extends GeneratedClient {
|
|
|
68
70
|
billing;
|
|
69
71
|
/** Managed Cursor accounts (platform operators only). */
|
|
70
72
|
cursorAccounts;
|
|
73
|
+
/** Platform provider standing, read-only (platform operators only). */
|
|
74
|
+
providerStanding;
|
|
71
75
|
platform;
|
|
72
76
|
search;
|
|
73
77
|
github;
|
|
74
78
|
manifest;
|
|
79
|
+
/**
|
|
80
|
+
* Skill operations, with `push` routed by artifact size over the transfer
|
|
81
|
+
* lane (stigmer#675) — shadows the inherited generated client so
|
|
82
|
+
* `stigmer.skill.push` simply works for any valid skill size.
|
|
83
|
+
*/
|
|
84
|
+
skill;
|
|
75
85
|
_tokenProvider;
|
|
76
86
|
constructor(config) {
|
|
77
87
|
validateConfig(config);
|
|
@@ -86,10 +96,12 @@ export class Stigmer extends GeneratedClient {
|
|
|
86
96
|
this.activity = new ActivityClient(transport);
|
|
87
97
|
this.billing = new BillingClient(transport);
|
|
88
98
|
this.cursorAccounts = new CursorAccountsClient(transport);
|
|
99
|
+
this.providerStanding = new ProviderStandingClient(transport);
|
|
89
100
|
this.platform = new PlatformClient(transport);
|
|
90
101
|
this.search = new SearchClient(transport);
|
|
91
102
|
this.github = new GitHubClient(transport);
|
|
92
103
|
this.manifest = new ManifestClient(transport);
|
|
104
|
+
this.skill = new RoutedSkillClient(transport, config.fetch);
|
|
93
105
|
if (this.defaultExecutionTarget != null) {
|
|
94
106
|
this._applyExecutionTargetDefaults();
|
|
95
107
|
}
|
package/stigmer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stigmer.js","sourceRoot":"","sources":["../src/stigmer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,cAAc,GAG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AW,EAAE,MAAM,CAAC,EAAE;YAC3E,CAAC,CAAC,KAAK,CACV,CAAC;IACN,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,iBAAiB;QACrB,OAAO,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IACrC,CAAC;CACF;AAED,SAAS,iBAAiB,CACxB,GAA0B;IAE1B,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,eAAe,CAAC,KAAK,CAAC;QAC/B,KAAK,OAAO;YACV,OAAO,eAAe,CAAC,KAAK,CAAC;QAC/B;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAC1B,KAAQ,EACR,MAAuB;IAEvB,IACE,KAAK,CAAC,eAAe,IAAI,IAAI;QAC7B,KAAK,CAAC,eAAe,KAAK,eAAe,CAAC,WAAW,EACrD,CAAC;QACD,OAAO,EAAE,GAAG,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IdentityAccount } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
|
|
2
|
+
import type { Organization } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/api_pb";
|
|
3
|
+
import type { IdentityAccountInput } from "./gen/identityaccount.js";
|
|
4
|
+
import type { OrganizationInput } from "./gen/organization.js";
|
|
5
|
+
/**
|
|
6
|
+
* Maps a loaded {@link Organization} to a complete {@link OrganizationInput}
|
|
7
|
+
* for `organization.update()`.
|
|
8
|
+
*
|
|
9
|
+
* Proto3 scalar defaults (empty string, `false`, enum `0`) are normalized to
|
|
10
|
+
* `undefined` — omitting them is wire-identical to sending the default, and
|
|
11
|
+
* it keeps the built proto in the builders' canonical shape.
|
|
12
|
+
*/
|
|
13
|
+
export declare function toOrganizationUpdateInput(org: Organization): OrganizationInput;
|
|
14
|
+
/**
|
|
15
|
+
* Maps a loaded {@link IdentityAccount} to a complete
|
|
16
|
+
* {@link IdentityAccountInput} for `identityAccount.update()`.
|
|
17
|
+
*
|
|
18
|
+
* The generated builder never sets `metadata.id`; the update pipeline
|
|
19
|
+
* locates the resource by org + slug instead (and authorizes against the
|
|
20
|
+
* loaded resource's id), so carrying `org` and `slug` here is what makes
|
|
21
|
+
* the update addressable.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toIdentityAccountUpdateInput(account: IdentityAccount): IdentityAccountInput;
|
|
24
|
+
//# sourceMappingURL=update-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-input.d.ts","sourceRoot":"","sources":["../src/update-input.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAEhG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2DAA2D,CAAC;AAE9F,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,uBAAuB,CAAC;AAc/B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,YAAY,GAChB,iBAAiB,CAkBnB;AAeD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,eAAe,GACvB,oBAAoB,CAoBtB"}
|
package/update-input.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Complete update-input mappers.
|
|
2
|
+
//
|
|
3
|
+
// The platform's update RPCs are FULL-SPEC REPLACEMENTS: the request spec
|
|
4
|
+
// wholesale overwrites the stored spec (both editions; only a small
|
|
5
|
+
// server-side preserve list of immutable identifiers survives). A client
|
|
6
|
+
// that sends only the fields it edits therefore silently WIPES every other
|
|
7
|
+
// mutable spec field — a data-loss bug class, not a single bug
|
|
8
|
+
// (stigmer/stigmer#293 Phase 1 surfaced it when `spec.preferences` set via
|
|
9
|
+
// CLI was dropped by a console profile save).
|
|
10
|
+
//
|
|
11
|
+
// These mappers are the structural fix: they convert a LOADED resource into
|
|
12
|
+
// a complete `*Input` for the generated update builders. Editors spread the
|
|
13
|
+
// mapper output and override only the fields they edit:
|
|
14
|
+
//
|
|
15
|
+
// await update({ ...toOrganizationUpdateInput(org), description: next });
|
|
16
|
+
//
|
|
17
|
+
// The `CompleteInput` mapped type removes optionality from every Input key,
|
|
18
|
+
// so when codegen adds a new Input field, compilation fails HERE — the one
|
|
19
|
+
// place a human must decide how the new field round-trips — instead of the
|
|
20
|
+
// field silently wiping in every subset-editing form.
|
|
21
|
+
//
|
|
22
|
+
// NESTED MESSAGE RULE: `CompleteInput` only sees TOP-LEVEL keys — a nested
|
|
23
|
+
// message (e.g. `preferences`) is one key whose object literal would keep
|
|
24
|
+
// compiling when codegen adds fields INSIDE it, recreating the wipe bug one
|
|
25
|
+
// level down. Every nested-message literal in this file must therefore be
|
|
26
|
+
// built by a dedicated `toXxxInput` helper whose return literal is itself
|
|
27
|
+
// typed `CompleteInput<XxxInput>`. Editors that override a nested message
|
|
28
|
+
// must spread the mapper's complete value and override only their fields:
|
|
29
|
+
//
|
|
30
|
+
// preferences: { ...mapped.preferences, standingContext: next }
|
|
31
|
+
/**
|
|
32
|
+
* Maps a loaded {@link Organization} to a complete {@link OrganizationInput}
|
|
33
|
+
* for `organization.update()`.
|
|
34
|
+
*
|
|
35
|
+
* Proto3 scalar defaults (empty string, `false`, enum `0`) are normalized to
|
|
36
|
+
* `undefined` — omitting them is wire-identical to sending the default, and
|
|
37
|
+
* it keeps the built proto in the builders' canonical shape.
|
|
38
|
+
*/
|
|
39
|
+
export function toOrganizationUpdateInput(org) {
|
|
40
|
+
const input = {
|
|
41
|
+
name: org.metadata?.name ?? "",
|
|
42
|
+
slug: org.metadata?.slug || undefined,
|
|
43
|
+
org: org.metadata?.org || org.metadata?.slug || "",
|
|
44
|
+
labels: nonEmptyLabels(org.metadata?.labels),
|
|
45
|
+
visibility: org.metadata?.visibility || undefined,
|
|
46
|
+
description: org.spec?.description || undefined,
|
|
47
|
+
logoUrl: org.spec?.logoUrl || undefined,
|
|
48
|
+
managementMode: org.spec?.managementMode || undefined,
|
|
49
|
+
identityProviderRef: toResourceRef(org.spec?.identityProviderRef),
|
|
50
|
+
externalOrgId: org.spec?.externalOrgId || undefined,
|
|
51
|
+
isPersonal: org.spec?.isPersonal || undefined,
|
|
52
|
+
preferences: org.spec?.preferences
|
|
53
|
+
? toOrganizationPreferencesInput(org.spec.preferences)
|
|
54
|
+
: undefined,
|
|
55
|
+
};
|
|
56
|
+
return input;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Maps loaded {@link OrganizationPreferences} to a complete
|
|
60
|
+
* {@link OrganizationPreferencesInput} (nested-message rule above).
|
|
61
|
+
*/
|
|
62
|
+
function toOrganizationPreferencesInput(preferences) {
|
|
63
|
+
const input = {
|
|
64
|
+
standingContext: preferences.standingContext || undefined,
|
|
65
|
+
};
|
|
66
|
+
return input;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Maps a loaded {@link IdentityAccount} to a complete
|
|
70
|
+
* {@link IdentityAccountInput} for `identityAccount.update()`.
|
|
71
|
+
*
|
|
72
|
+
* The generated builder never sets `metadata.id`; the update pipeline
|
|
73
|
+
* locates the resource by org + slug instead (and authorizes against the
|
|
74
|
+
* loaded resource's id), so carrying `org` and `slug` here is what makes
|
|
75
|
+
* the update addressable.
|
|
76
|
+
*/
|
|
77
|
+
export function toIdentityAccountUpdateInput(account) {
|
|
78
|
+
const input = {
|
|
79
|
+
name: account.metadata?.name ?? "",
|
|
80
|
+
slug: account.metadata?.slug || undefined,
|
|
81
|
+
org: account.metadata?.org ?? "",
|
|
82
|
+
labels: nonEmptyLabels(account.metadata?.labels),
|
|
83
|
+
visibility: account.metadata?.visibility || undefined,
|
|
84
|
+
idpId: account.spec?.idpId ?? "",
|
|
85
|
+
email: account.spec?.email || undefined,
|
|
86
|
+
firstName: account.spec?.firstName || undefined,
|
|
87
|
+
lastName: account.spec?.lastName || undefined,
|
|
88
|
+
pictureUrl: account.spec?.pictureUrl || undefined,
|
|
89
|
+
isMachineAccount: account.spec?.isMachineAccount || undefined,
|
|
90
|
+
provisioningMode: account.spec?.provisioningMode || undefined,
|
|
91
|
+
identityProviderRef: toResourceRef(account.spec?.identityProviderRef),
|
|
92
|
+
preferences: account.spec?.preferences
|
|
93
|
+
? toIdentityAccountPreferencesInput(account.spec.preferences)
|
|
94
|
+
: undefined,
|
|
95
|
+
};
|
|
96
|
+
return input;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Maps loaded {@link IdentityAccountPreferences} to a complete
|
|
100
|
+
* {@link IdentityAccountPreferencesInput} (nested-message rule above).
|
|
101
|
+
*/
|
|
102
|
+
function toIdentityAccountPreferencesInput(preferences) {
|
|
103
|
+
const input = {
|
|
104
|
+
standingContext: preferences.standingContext || undefined,
|
|
105
|
+
defaultHarness: preferences.defaultHarness || undefined,
|
|
106
|
+
defaultNativeModel: preferences.defaultNativeModel || undefined,
|
|
107
|
+
defaultCursorModel: preferences.defaultCursorModel || undefined,
|
|
108
|
+
};
|
|
109
|
+
return input;
|
|
110
|
+
}
|
|
111
|
+
function nonEmptyLabels(labels) {
|
|
112
|
+
return labels && Object.keys(labels).length > 0 ? labels : undefined;
|
|
113
|
+
}
|
|
114
|
+
function toResourceRef(ref) {
|
|
115
|
+
// The builders treat a ref without org and slug as absent; mirror that so
|
|
116
|
+
// an empty message round-trips to "no reference".
|
|
117
|
+
if (!ref || (!ref.org && !ref.slug))
|
|
118
|
+
return undefined;
|
|
119
|
+
return {
|
|
120
|
+
org: ref.org,
|
|
121
|
+
slug: ref.slug,
|
|
122
|
+
...(ref.version && { version: ref.version }),
|
|
123
|
+
...(ref.kind && { kind: ref.kind }),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=update-input.js.map
|
|
@@ -0,0 +1 @@
|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