@hasna/skills 0.5.0 → 0.5.2

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,5 @@
1
+ import { type LeaveRemoteWorkspace } from "./remote-workspace-leave.js";
2
+ import { type RemoteWorkspaceContext, type RemoteWorkspaceSession, type RemoteAccountWorkspaceDiscovery } from "./remote-workspace-selection.js";
1
3
  import { type RemoteWorkspaceMembersOptions } from "./remote-workspace.js";
2
4
  import { type SetRemoteWorkspaceMemberRole, type RemoveRemoteWorkspaceMember } from "./remote-workspace.js";
3
5
  import { type UpdateRemoteProfile, type UpdateRemoteWorkspace } from "./remote-profile.js";
@@ -24,23 +26,30 @@ export declare class RemoteSkillsAuthClient {
24
26
  startDevice(): Promise<any>;
25
27
  pollDevice(deviceCode: string): Promise<any>;
26
28
  private sessionClient;
27
- createApiKey(email: string, code: string, name: string, scopes?: string[]): Promise<{
29
+ /** Discover memberships with fresh sign-in. No key or session is saved. */
30
+ listAccountWorkspaces(email: string, code: string, expectedUserId?: string): Promise<RemoteAccountWorkspaceDiscovery>;
31
+ /** Contains a secret session token. Selection never creates or stores an API key. */
32
+ switchWorkspace(email: string, code: string, context: RemoteWorkspaceContext): Promise<RemoteWorkspaceSession>;
33
+ private workspaceLogin;
34
+ createApiKey(email: string, code: string, name: string, scopes?: string[], context?: RemoteWorkspaceContext): Promise<{
28
35
  [field: string]: unknown;
29
36
  key: string;
30
37
  }>;
31
- listApiKeys(email: string, code: string): Promise<Record<string, unknown>[]>;
32
- revokeApiKey(email: string, code: string, keyId: string): Promise<Record<string, unknown>>;
38
+ listApiKeys(email: string, code: string, context?: RemoteWorkspaceContext): Promise<Record<string, unknown>[]>;
39
+ revokeApiKey(email: string, code: string, keyId: string, context?: RemoteWorkspaceContext): Promise<Record<string, unknown>>;
33
40
  /** Reauthentication is ephemeral: it never replaces a saved key or profile. */
34
- updateProfile(email: string, code: string, input: UpdateRemoteProfile): Promise<{
41
+ updateProfile(email: string, code: string, input: UpdateRemoteProfile, context?: RemoteWorkspaceContext): Promise<{
35
42
  user: import("./remote-profile.js").RemoteCustomerProfile;
36
43
  }>;
37
- updateCurrentWorkspace(email: string, code: string, input: UpdateRemoteWorkspace): Promise<{
44
+ updateCurrentWorkspace(email: string, code: string, input: UpdateRemoteWorkspace, context?: RemoteWorkspaceContext): Promise<{
38
45
  organization: import("./remote-profile.js").RemoteCurrentWorkspace;
39
46
  }>;
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>;
47
+ /** Fresh owner/admin session; explicit context survives default-workspace OTP selection. */
48
+ listWorkspaceMembers(email: string, code: string, options?: RemoteWorkspaceMembersOptions, context?: RemoteWorkspaceContext): Promise<import("./remote-workspace.js").RemoteWorkspaceMembersPage>;
49
+ setWorkspaceMemberRole(email: string, code: string, membershipId: string, input: SetRemoteWorkspaceMemberRole, context?: RemoteWorkspaceContext): Promise<import("./remote-workspace.js").RemoteWorkspaceMemberRoleResult>;
50
+ /** Fresh verification binds the exact observed incarnation before a single confirmed leave. */
51
+ leaveWorkspace(email: string, code: string, context: RemoteWorkspaceContext, input: LeaveRemoteWorkspace): Promise<import("./remote-workspace-leave.js").RemoteWorkspaceLeaveResult>;
52
+ removeWorkspaceMember(email: string, code: string, membershipId: string, input: RemoveRemoteWorkspaceMember, context?: RemoteWorkspaceContext): Promise<import("./remote-workspace.js").RemoteWorkspaceMemberRemovalResult>;
44
53
  /** Common auth transport used by CLI login, preserving the selected instance through awaits. */
45
54
  request(path: string, options?: RequestInit): Promise<any>;
46
55
  }
@@ -1,3 +1,5 @@
1
+ import { type LeaveRemoteWorkspace, type RemoteWorkspaceLeaveResult } from "./remote-workspace-leave.js";
2
+ import { type RemoteWorkspaceContext, type RemoteAccountWorkspaces, type RemoteWorkspaceSession, type RemoteWorkspaceSelectionErrorCode } from "./remote-workspace-selection.js";
1
3
  import { type RemoteWorkspaceMembersOptions, type RemoteWorkspaceMembersPage } from "./remote-workspace.js";
2
4
  import { type RemoteWorkspaceMemberErrorCode, type SetRemoteWorkspaceMemberRole, type RemoveRemoteWorkspaceMember, type RemoteWorkspaceMemberRoleResult, type RemoteWorkspaceMemberRemovalResult } from "./remote-workspace.js";
3
5
  import { type RemoteSkillRunContract } from "./remote-run-contract.js";
@@ -27,6 +29,11 @@ export declare class RemoteWorkspaceMemberError extends RemoteRequestError {
27
29
  readonly code: RemoteWorkspaceMemberErrorCode;
28
30
  constructor(path: string, code: RemoteWorkspaceMemberErrorCode);
29
31
  }
32
+ /** Fixed text for recognized workspace refusals; no reflected server error payload. */
33
+ export declare class RemoteWorkspaceSelectionError extends RemoteRequestError {
34
+ readonly code: RemoteWorkspaceSelectionErrorCode;
35
+ constructor(path: string, code: RemoteWorkspaceSelectionErrorCode);
36
+ }
30
37
  /** A recognized unavailable capability; all displayed text is client-owned. */
31
38
  export declare class RemoteCapabilityUnavailableError extends RemoteRequestError {
32
39
  readonly code: "SUBSCRIPTION_CHECKOUT_UNAVAILABLE";
@@ -119,6 +126,11 @@ export declare class RemoteSkillsClient {
119
126
  /** Quote first and fail closed when the caller has not approved the required credits. */
120
127
  submitQuotedRun(slug: string, input?: Record<string, unknown>, args?: string[], approval?: RemoteRunApproval): Promise<RemoteSkillRunContract>;
121
128
  getIdentity(): Promise<Record<string, unknown>>;
129
+ /** List memberships with the current interactive session; never writes credentials. */
130
+ listAccountWorkspaces(expectedUserId?: string): Promise<RemoteAccountWorkspaces>;
131
+ /** Return a new ephemeral session; this client and any saved key/profile stay unchanged. */
132
+ switchWorkspace(context: RemoteWorkspaceContext): Promise<RemoteWorkspaceSession>;
133
+ private requestWorkspaceSelection;
122
134
  /** Requires a customer session; API keys and support impersonation cannot edit names. */
123
135
  updateProfile(input: UpdateRemoteProfile): Promise<{
124
136
  user: import("./remote-profile.js").RemoteCustomerProfile;
@@ -134,6 +146,8 @@ export declare class RemoteSkillsClient {
134
146
  /** Removes only this incarnation. A successful tombstone replay is returned unchanged. */
135
147
  removeWorkspaceMember(membershipId: string, input: RemoveRemoteWorkspaceMember): Promise<RemoteWorkspaceMemberRemovalResult>;
136
148
  private requestWorkspaceMember;
149
+ /** Leave only the explicitly confirmed current incarnation, once. No credential writes or retries. */
150
+ leaveWorkspace(context: RemoteWorkspaceContext, input: LeaveRemoteWorkspace): Promise<RemoteWorkspaceLeaveResult>;
137
151
  listApiKeys(): Promise<Record<string, unknown>[]>;
138
152
  createApiKey(name: string, scopes?: string[]): Promise<{
139
153
  key: string;
@@ -0,0 +1,52 @@
1
+ import { type RemoteWorkspaceContext } from "./remote-workspace-selection.js";
2
+ import type { RemoteCustomerRole } from "./remote-profile.js";
3
+ export type LeaveRemoteWorkspace = Readonly<{
4
+ expectedRole: RemoteCustomerRole;
5
+ confirm: true;
6
+ }>;
7
+ export type RemoteWorkspaceLeaveResult = {
8
+ organizationId: string;
9
+ membershipId: string;
10
+ removed: true;
11
+ signInRequired: true;
12
+ };
13
+ export declare class WorkspaceLeaveInputError extends Error {
14
+ constructor();
15
+ }
16
+ export declare function workspaceLeaveInput(context: RemoteWorkspaceContext, input: LeaveRemoteWorkspace): {
17
+ context: Readonly<{
18
+ userId: string;
19
+ membershipId: string;
20
+ }>;
21
+ input: {
22
+ expectedRole: RemoteCustomerRole;
23
+ confirm: true;
24
+ };
25
+ body: {
26
+ membershipId: string;
27
+ expectedRole: RemoteCustomerRole;
28
+ };
29
+ };
30
+ export declare const workspaceLeaveFailures: {
31
+ readonly INVALID_REQUEST: readonly [400, "Provide the exact current membership and expected role."];
32
+ readonly ACCOUNT_UNAVAILABLE: readonly [403, "Account is unavailable."];
33
+ readonly INTERACTIVE_SESSION_REQUIRED: readonly [403, "Fresh interactive sign-in is required to leave a workspace."];
34
+ readonly MEMBERSHIP_ROLE_CHANGED: readonly [409, "Your role changed. Sign in and inspect the workspace before leaving."];
35
+ readonly LAST_OWNER_REQUIRED: readonly [409, "The workspace must retain another active owner."];
36
+ readonly LAST_WORKSPACE_REQUIRED: readonly [409, "Another available workspace is required before leaving."];
37
+ readonly MEMBERSHIP_BUSY: readonly [503, "Membership is busy. Inspect the workspace before another leave action."];
38
+ };
39
+ export type RemoteWorkspaceLeaveErrorCode = keyof typeof workspaceLeaveFailures;
40
+ export declare class RemoteWorkspaceLeaveError extends Error {
41
+ readonly code: RemoteWorkspaceLeaveErrorCode;
42
+ readonly status: number;
43
+ constructor(code: RemoteWorkspaceLeaveErrorCode);
44
+ }
45
+ export declare class RemoteWorkspaceLeaveUnconfirmedError extends Error {
46
+ readonly code = "WORKSPACE_LEAVE_UNCONFIRMED";
47
+ constructor();
48
+ }
49
+ export declare function workspaceLeaveFailure(value: unknown, status: number): RemoteWorkspaceLeaveErrorCode | null;
50
+ export declare function parseWorkspaceLeaveResult(value: unknown, membershipId: string, organizationId: string): RemoteWorkspaceLeaveResult;
51
+ /** A configured profile may constrain an explicit leave, never retarget it. */
52
+ export declare function workspaceLeaveProfileContext(membershipId: string, userId: string | undefined, profile?: RemoteWorkspaceContext): RemoteWorkspaceContext;
@@ -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,8 @@ 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";
43
+ export type { LeaveRemoteWorkspace, RemoteWorkspaceLeaveResult, RemoteWorkspaceLeaveErrorCode } from "../lib/remote-workspace-leave.js";
44
+ export { WorkspaceLeaveInputError, RemoteWorkspaceLeaveError, RemoteWorkspaceLeaveUnconfirmedError } from "../lib/remote-workspace-leave.js";