@hasna/skills 0.5.0 → 0.5.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.
@@ -1,3 +1,4 @@
1
+ import { type RemoteWorkspaceContext, type RemoteWorkspaceSession, type RemoteAccountWorkspaceDiscovery } from "./remote-workspace-selection.js";
1
2
  import { type RemoteWorkspaceMembersOptions } from "./remote-workspace.js";
2
3
  import { type SetRemoteWorkspaceMemberRole, type RemoveRemoteWorkspaceMember } from "./remote-workspace.js";
3
4
  import { type UpdateRemoteProfile, type UpdateRemoteWorkspace } from "./remote-profile.js";
@@ -24,23 +25,28 @@ export declare class RemoteSkillsAuthClient {
24
25
  startDevice(): Promise<any>;
25
26
  pollDevice(deviceCode: string): Promise<any>;
26
27
  private sessionClient;
27
- createApiKey(email: string, code: string, name: string, scopes?: string[]): Promise<{
28
+ /** Discover memberships with fresh sign-in. No key or session is saved. */
29
+ listAccountWorkspaces(email: string, code: string, expectedUserId?: string): Promise<RemoteAccountWorkspaceDiscovery>;
30
+ /** Contains a secret session token. Selection never creates or stores an API key. */
31
+ switchWorkspace(email: string, code: string, context: RemoteWorkspaceContext): Promise<RemoteWorkspaceSession>;
32
+ private workspaceLogin;
33
+ createApiKey(email: string, code: string, name: string, scopes?: string[], context?: RemoteWorkspaceContext): Promise<{
28
34
  [field: string]: unknown;
29
35
  key: string;
30
36
  }>;
31
- listApiKeys(email: string, code: string): Promise<Record<string, unknown>[]>;
32
- revokeApiKey(email: string, code: string, keyId: string): Promise<Record<string, unknown>>;
37
+ listApiKeys(email: string, code: string, context?: RemoteWorkspaceContext): Promise<Record<string, unknown>[]>;
38
+ revokeApiKey(email: string, code: string, keyId: string, context?: RemoteWorkspaceContext): Promise<Record<string, unknown>>;
33
39
  /** Reauthentication is ephemeral: it never replaces a saved key or profile. */
34
- updateProfile(email: string, code: string, input: UpdateRemoteProfile): Promise<{
40
+ updateProfile(email: string, code: string, input: UpdateRemoteProfile, context?: RemoteWorkspaceContext): Promise<{
35
41
  user: import("./remote-profile.js").RemoteCustomerProfile;
36
42
  }>;
37
- updateCurrentWorkspace(email: string, code: string, input: UpdateRemoteWorkspace): Promise<{
43
+ updateCurrentWorkspace(email: string, code: string, input: UpdateRemoteWorkspace, context?: RemoteWorkspaceContext): Promise<{
38
44
  organization: import("./remote-profile.js").RemoteCurrentWorkspace;
39
45
  }>;
40
- /** Fresh owner/admin session; no saved credential or profile is replaced. */
41
- listWorkspaceMembers(email: string, code: string, options?: RemoteWorkspaceMembersOptions): Promise<import("./remote-workspace.js").RemoteWorkspaceMembersPage>;
42
- setWorkspaceMemberRole(email: string, code: string, membershipId: string, input: SetRemoteWorkspaceMemberRole): Promise<import("./remote-workspace.js").RemoteWorkspaceMemberRoleResult>;
43
- removeWorkspaceMember(email: string, code: string, membershipId: string, input: RemoveRemoteWorkspaceMember): Promise<import("./remote-workspace.js").RemoteWorkspaceMemberRemovalResult>;
46
+ /** Fresh owner/admin session; explicit context survives default-workspace OTP selection. */
47
+ listWorkspaceMembers(email: string, code: string, options?: RemoteWorkspaceMembersOptions, context?: RemoteWorkspaceContext): Promise<import("./remote-workspace.js").RemoteWorkspaceMembersPage>;
48
+ setWorkspaceMemberRole(email: string, code: string, membershipId: string, input: SetRemoteWorkspaceMemberRole, context?: RemoteWorkspaceContext): Promise<import("./remote-workspace.js").RemoteWorkspaceMemberRoleResult>;
49
+ removeWorkspaceMember(email: string, code: string, membershipId: string, input: RemoveRemoteWorkspaceMember, context?: RemoteWorkspaceContext): Promise<import("./remote-workspace.js").RemoteWorkspaceMemberRemovalResult>;
44
50
  /** Common auth transport used by CLI login, preserving the selected instance through awaits. */
45
51
  request(path: string, options?: RequestInit): Promise<any>;
46
52
  }
@@ -1,3 +1,4 @@
1
+ import { type RemoteWorkspaceContext, type RemoteAccountWorkspaces, type RemoteWorkspaceSession, type RemoteWorkspaceSelectionErrorCode } from "./remote-workspace-selection.js";
1
2
  import { type RemoteWorkspaceMembersOptions, type RemoteWorkspaceMembersPage } from "./remote-workspace.js";
2
3
  import { type RemoteWorkspaceMemberErrorCode, type SetRemoteWorkspaceMemberRole, type RemoveRemoteWorkspaceMember, type RemoteWorkspaceMemberRoleResult, type RemoteWorkspaceMemberRemovalResult } from "./remote-workspace.js";
3
4
  import { type RemoteSkillRunContract } from "./remote-run-contract.js";
@@ -27,6 +28,11 @@ export declare class RemoteWorkspaceMemberError extends RemoteRequestError {
27
28
  readonly code: RemoteWorkspaceMemberErrorCode;
28
29
  constructor(path: string, code: RemoteWorkspaceMemberErrorCode);
29
30
  }
31
+ /** Fixed text for recognized workspace refusals; no reflected server error payload. */
32
+ export declare class RemoteWorkspaceSelectionError extends RemoteRequestError {
33
+ readonly code: RemoteWorkspaceSelectionErrorCode;
34
+ constructor(path: string, code: RemoteWorkspaceSelectionErrorCode);
35
+ }
30
36
  /** A recognized unavailable capability; all displayed text is client-owned. */
31
37
  export declare class RemoteCapabilityUnavailableError extends RemoteRequestError {
32
38
  readonly code: "SUBSCRIPTION_CHECKOUT_UNAVAILABLE";
@@ -119,6 +125,11 @@ export declare class RemoteSkillsClient {
119
125
  /** Quote first and fail closed when the caller has not approved the required credits. */
120
126
  submitQuotedRun(slug: string, input?: Record<string, unknown>, args?: string[], approval?: RemoteRunApproval): Promise<RemoteSkillRunContract>;
121
127
  getIdentity(): Promise<Record<string, unknown>>;
128
+ /** List memberships with the current interactive session; never writes credentials. */
129
+ listAccountWorkspaces(expectedUserId?: string): Promise<RemoteAccountWorkspaces>;
130
+ /** Return a new ephemeral session; this client and any saved key/profile stay unchanged. */
131
+ switchWorkspace(context: RemoteWorkspaceContext): Promise<RemoteWorkspaceSession>;
132
+ private requestWorkspaceSelection;
122
133
  /** Requires a customer session; API keys and support impersonation cannot edit names. */
123
134
  updateProfile(input: UpdateRemoteProfile): Promise<{
124
135
  user: import("./remote-profile.js").RemoteCustomerProfile;
@@ -0,0 +1,58 @@
1
+ import type { RemoteCurrentWorkspace, RemoteCustomerProfile, RemoteCustomerRole } from "./remote-profile.js";
2
+ /** An observed identity and exact membership incarnation, never a slug or cached role. */
3
+ export type RemoteWorkspaceContext = Readonly<{
4
+ userId: string;
5
+ membershipId: string;
6
+ }>;
7
+ export type RemoteAccountWorkspace = {
8
+ membershipId: string;
9
+ organization: RemoteCurrentWorkspace;
10
+ role: RemoteCustomerRole;
11
+ current: boolean;
12
+ };
13
+ export type RemoteAccountWorkspaces = {
14
+ workspaces: RemoteAccountWorkspace[];
15
+ };
16
+ export type RemoteWorkspaceIdentity = {
17
+ user: RemoteCustomerProfile & {
18
+ membershipId: string;
19
+ };
20
+ organization: RemoteCurrentWorkspace;
21
+ };
22
+ /** Contains a secret. SDK callers own its lifetime; never print or persist it implicitly. */
23
+ export type RemoteWorkspaceSession = RemoteWorkspaceIdentity & {
24
+ token: string;
25
+ };
26
+ export type RemoteAccountWorkspaceDiscovery = RemoteAccountWorkspaces & {
27
+ userId: string;
28
+ };
29
+ export declare const invalidWorkspaceResult = "The server returned an invalid workspace selection result.";
30
+ export declare class WorkspaceContextInputError extends Error {
31
+ constructor();
32
+ }
33
+ export declare class WorkspaceIdentityMismatchError extends Error {
34
+ constructor();
35
+ }
36
+ export declare function workspaceExpectedUserId(value: unknown): string;
37
+ /** Copy before the first await: caller mutations cannot retarget verification. */
38
+ export declare function workspaceContext(value: unknown): RemoteWorkspaceContext;
39
+ /** Project documented fields only; server extras cannot reach display metadata. */
40
+ export declare function parseAccountWorkspaces(value: unknown): RemoteAccountWorkspaces;
41
+ export declare function parseWorkspaceIdentity(value: unknown, expectedUserId: string): RemoteWorkspaceIdentity;
42
+ /** The service still verifies the token; response metadata never grants authority. */
43
+ export declare function parseWorkspaceSession(value: unknown, expected: RemoteWorkspaceContext): RemoteWorkspaceSession;
44
+ /** Fresh verification does not require newer workspace metadata from default-only servers. */
45
+ export declare function parseWorkspaceLogin(value: unknown, expectedUserId?: string): {
46
+ token: string;
47
+ userId: string;
48
+ };
49
+ export declare const workspaceSelectionFailures: {
50
+ readonly INVALID_WORKSPACE_SELECTION: readonly [400, "Provide only the exact membership ID from your workspace list."];
51
+ readonly SESSION_EXPIRED: readonly [401, "Sign in again before selecting a workspace."];
52
+ readonly ACCOUNT_UNAVAILABLE: readonly [403, "Account is unavailable."];
53
+ readonly INTERACTIVE_SESSION_REQUIRED: readonly [403, "Interactive sign-in is required to select a workspace."];
54
+ readonly WORKSPACE_UNAVAILABLE: readonly [404, "Workspace is unavailable. Refresh your workspace list."];
55
+ readonly WORKSPACE_BUSY: readonly [503, "Workspace is busy. Refresh before retrying."];
56
+ };
57
+ export type RemoteWorkspaceSelectionErrorCode = keyof typeof workspaceSelectionFailures;
58
+ export declare function workspaceSelectionFailure(value: unknown, status: number): RemoteWorkspaceSelectionErrorCode | null;
@@ -0,0 +1,49 @@
1
+ type Env = Record<string, string | undefined>;
2
+ export declare class WorkspaceProfileError extends Error {
3
+ }
4
+ /** Capture actual key authority before OTP; cached identity never supplies authority. */
5
+ export declare function prepareProfileWorkspace(action: string, source?: Env): {
6
+ origin: string;
7
+ resolve(): Promise<{
8
+ origin: string;
9
+ context: undefined;
10
+ unchanged: () => void;
11
+ } | {
12
+ origin: string;
13
+ context: Readonly<{
14
+ userId: string;
15
+ membershipId: string;
16
+ }>;
17
+ unchanged: () => void;
18
+ }>;
19
+ };
20
+ export declare function captureProfileWorkspace(action: string, source?: Env): Promise<{
21
+ origin: string;
22
+ context: undefined;
23
+ unchanged: () => void;
24
+ } | {
25
+ origin: string;
26
+ context: Readonly<{
27
+ userId: string;
28
+ membershipId: string;
29
+ }>;
30
+ unchanged: () => void;
31
+ }>;
32
+ /** Own only the explicitly named profile; injected credentials may not hide enrollment. */
33
+ export declare function prepareWorkspaceEnrollment(membershipId: string, source?: Env): Promise<{
34
+ profile: string;
35
+ origin: string;
36
+ complete(email: string, code: string): Promise<{
37
+ status: string;
38
+ profile: string;
39
+ apiUrl: string;
40
+ userId: string;
41
+ email: string;
42
+ membershipId: string;
43
+ organization: string;
44
+ organizationId: string;
45
+ role: import("./remote-profile.js").RemoteCustomerRole;
46
+ keyCreated: boolean;
47
+ }>;
48
+ }>;
49
+ export {};
@@ -37,3 +37,6 @@ export { RemoteSkillsAuthClient, HostedApiError } from "../lib/remote-auth.js";
37
37
  export type { RemoteWorkspaceMember, RemoteWorkspaceMembersPage, RemoteWorkspaceMembersOptions } from "../lib/remote-workspace.js";
38
38
  export type { SetRemoteWorkspaceMemberRole, RemoveRemoteWorkspaceMember, RemoteWorkspaceMemberRoleResult, RemoteWorkspaceMemberRemovalResult, RemoteWorkspaceMemberErrorCode } from "../lib/remote-workspace.js";
39
39
  export type { RemoteCustomerRole, RemoteCustomerProfile, RemoteCurrentWorkspace, UpdateRemoteProfile, UpdateRemoteWorkspace } from "../lib/remote-profile.js";
40
+ export type { RemoteWorkspaceContext, RemoteAccountWorkspace, RemoteAccountWorkspaces, RemoteWorkspaceIdentity, RemoteWorkspaceSession, RemoteAccountWorkspaceDiscovery, RemoteWorkspaceSelectionErrorCode } from "../lib/remote-workspace-selection.js";
41
+ export { WorkspaceContextInputError, WorkspaceIdentityMismatchError } from "../lib/remote-workspace-selection.js";
42
+ export { RemoteWorkspaceSelectionError } from "../lib/remote-client.js";