@hasna/skills 0.8.1 → 0.8.3
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/README.md +110 -0
- package/bin/index.js +2768 -983
- package/bin/mcp.js +2071 -475
- package/bin/migrate.js +82 -24
- package/bin/server.js +1446 -654
- package/bin/worker.js +582 -274
- package/dist/admin-contract.js +8 -8
- package/dist/cli/commands/grants.d.ts +2 -0
- package/dist/index.js +168 -168
- package/dist/lib/execution-grant-client.d.ts +5 -0
- package/dist/lib/execution-grants.d.ts +49 -0
- package/dist/lib/execution-secrets.d.ts +40 -0
- package/dist/lib/selected-manifest.d.ts +6 -0
- package/dist/lib/selected-run.d.ts +28 -0
- package/dist/sdk/index.d.ts +4 -0
- package/dist/sdk/index.js +41008 -26743
- package/dist/server/execution-grant-store.d.ts +29 -0
- package/dist/server/execution-grants-api.d.ts +4 -0
- package/dist/server/sqlite-store.d.ts +2 -0
- package/dist/server/store.d.ts +3 -0
- package/dist/server/types.d.ts +2 -0
- package/migrations/postgres/0009_execution_grants.sql +15 -0
- package/migrations/sqlite/0009_execution_grants.sql +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ExecutionGrant, type ExecutionGrantPolicy, type ExecutionGrantRequest, type ResolvedExecutionGrant } from "./execution-grants.js";
|
|
2
|
+
export declare function readExecutionGrantPolicy(profileId: string, revision?: string): Promise<ExecutionGrantPolicy>;
|
|
3
|
+
export declare function saveExecutionGrantPolicy(profileId: string, grants: ExecutionGrant[], revision?: string): Promise<ExecutionGrantPolicy>;
|
|
4
|
+
/** No disk cache: every execution obtains a current decision from its configured Skills authority. */
|
|
5
|
+
export declare function resolveExecutionGrant(input: ExecutionGrantRequest): Promise<ResolvedExecutionGrant>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { SelectedSecretBindings } from "./execution-secrets.js";
|
|
2
|
+
export declare const MAX_EXECUTION_GRANTS = 256;
|
|
3
|
+
export declare const MAX_EXECUTION_GRANT_BYTES: number;
|
|
4
|
+
export interface ExecutionGrant {
|
|
5
|
+
id: string;
|
|
6
|
+
target: "local";
|
|
7
|
+
selection: {
|
|
8
|
+
slug: string;
|
|
9
|
+
version: string;
|
|
10
|
+
bundleDigest: string;
|
|
11
|
+
};
|
|
12
|
+
actors: string[];
|
|
13
|
+
/** Canonical directory conditions, not cryptographic machine attestation. */
|
|
14
|
+
consumers: {
|
|
15
|
+
stationId: string;
|
|
16
|
+
workspaceDirectory: string;
|
|
17
|
+
includeDescendants?: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
secretsAuthority: string;
|
|
20
|
+
bindings: Record<string, string>;
|
|
21
|
+
expiresAt?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ExecutionGrantPolicy {
|
|
24
|
+
schema: "hasna.skills-execution-grants.v1";
|
|
25
|
+
profileId: string;
|
|
26
|
+
workspaceId: string;
|
|
27
|
+
revision: string;
|
|
28
|
+
previousRevision: string | null;
|
|
29
|
+
updatedAt: string;
|
|
30
|
+
actorId: string;
|
|
31
|
+
grants: ExecutionGrant[];
|
|
32
|
+
}
|
|
33
|
+
export interface ExecutionGrantRequest {
|
|
34
|
+
selection: SelectedSecretBindings["selection"];
|
|
35
|
+
consumer: SelectedSecretBindings["consumer"];
|
|
36
|
+
}
|
|
37
|
+
export interface ResolvedExecutionGrant {
|
|
38
|
+
policyRevision: string;
|
|
39
|
+
grantId: string;
|
|
40
|
+
bindings: SelectedSecretBindings;
|
|
41
|
+
}
|
|
42
|
+
export declare function grantIdentifier(v: unknown): v is string;
|
|
43
|
+
export declare function grantRecord(v: unknown): v is Record<string, unknown>;
|
|
44
|
+
export declare function grantWorkspace(v: unknown): v is string;
|
|
45
|
+
export declare function grantDirectoryContains(root: string, directory: string, descendants?: boolean): boolean;
|
|
46
|
+
export declare function validateExecutionGrants(value: unknown): ExecutionGrant[];
|
|
47
|
+
export declare function validateExecutionGrantPolicy(value: unknown): ExecutionGrantPolicy;
|
|
48
|
+
export declare function validateExecutionGrantRequest(value: unknown): ExecutionGrantRequest;
|
|
49
|
+
export declare function executionGrantMatches(g: ExecutionGrant, r: ExecutionGrantRequest, actorId: string, now?: number): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ResolvedSkillSelection } from "../types/skill-selection.js";
|
|
2
|
+
export interface SelectedSecretBindings {
|
|
3
|
+
schema: "hasna.skills-secret-bindings.v1";
|
|
4
|
+
selection: Pick<ResolvedSkillSelection, "authority" | "workspaceId" | "profileRevision" | "slug" | "version" | "bundleDigest"> & {
|
|
5
|
+
profileId: string;
|
|
6
|
+
};
|
|
7
|
+
consumer: {
|
|
8
|
+
stationId: string;
|
|
9
|
+
workspaceDirectory: string;
|
|
10
|
+
};
|
|
11
|
+
/** Exact canonical /v1 authority of the independently configured Secrets client. */
|
|
12
|
+
secretsAuthority: string;
|
|
13
|
+
/** Declared environment name -> vault key. Values are resolved freshly for each run. */
|
|
14
|
+
bindings: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
export interface SelectedSecretsClient {
|
|
17
|
+
readonly baseUrl: string;
|
|
18
|
+
getSecret(query: {
|
|
19
|
+
key: string;
|
|
20
|
+
}, init?: RequestInit): Promise<{
|
|
21
|
+
key: string;
|
|
22
|
+
value: string;
|
|
23
|
+
expires_at?: string | null;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export interface SelectedSecretScope {
|
|
27
|
+
selection: ResolvedSkillSelection;
|
|
28
|
+
profileId: string;
|
|
29
|
+
cwd: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function selectedSecretBindingsTemplate(scope: SelectedSecretScope, names: string[], createClient?: () => SelectedSecretsClient): SelectedSecretBindings;
|
|
32
|
+
/** Runtime controls must not be supplied as credentials, even by a reviewed binding. */
|
|
33
|
+
export declare function declaredSecretNames(value: unknown): string[];
|
|
34
|
+
/** Reading is bounded and rejects symlinks/devices. Parsing errors never echo file contents. */
|
|
35
|
+
export declare function readSelectedSecretBindings(path: string): SelectedSecretBindings;
|
|
36
|
+
/** Validate every grant before constructing a client or reading any secret. */
|
|
37
|
+
export declare function validateSelectedSecretBindings(value: unknown, scope: SelectedSecretScope, names: string[]): SelectedSecretBindings;
|
|
38
|
+
export declare function resolveSelectedSecrets(bindings: SelectedSecretBindings, createClient?: () => SelectedSecretsClient): Promise<Record<string, string>>;
|
|
39
|
+
/** Limit accidental disclosure in child output. This is not a sandbox for hostile code. */
|
|
40
|
+
export declare function redactExecutionSecrets(text: string, env: Record<string, string>): string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { type ExecutionGrantRequest, type ResolvedExecutionGrant } from "./execution-grants.js";
|
|
1
2
|
import type { ResolvedSkillSelection } from "../types/skill-selection.js";
|
|
2
3
|
import type { SkillBundleEntry } from "./skill-bundle.js";
|
|
3
4
|
import { type SelectionResolverOptions } from "./selection-resolver.js";
|
|
5
|
+
import { type SelectedSecretBindings, type SelectedSecretsClient } from "./execution-secrets.js";
|
|
4
6
|
export interface ResolvedSelectedRun {
|
|
5
7
|
selection: ResolvedSkillSelection;
|
|
8
|
+
profileId: string;
|
|
6
9
|
kind: "instruction" | "executable";
|
|
7
10
|
entries: SkillBundleEntry[];
|
|
8
11
|
manifest: Record<string, any>;
|
|
@@ -17,12 +20,37 @@ export interface SelectedLocalRunOptions {
|
|
|
17
20
|
timeoutMs?: number;
|
|
18
21
|
/** Only explicitly supplied environment values are available to declared secret references. */
|
|
19
22
|
env?: Record<string, string>;
|
|
23
|
+
/** Explicit value-free vault grants; mutually exclusive with env. */
|
|
24
|
+
secretBindings?: SelectedSecretBindings;
|
|
25
|
+
/** SDK injection seam. The default uses the independently configured Secrets SDK. */
|
|
26
|
+
createSecretsClient?: () => SelectedSecretsClient;
|
|
27
|
+
/** Disable network authorization for explicit cached execution; declared secrets then need caller bindings. */
|
|
28
|
+
sharedExecutionGrants?: boolean;
|
|
29
|
+
/** SDK seam for current shared authorization; responses still undergo exact binding validation. */
|
|
30
|
+
resolveExecutionGrant?: (request: ExecutionGrantRequest) => Promise<ResolvedExecutionGrant>;
|
|
20
31
|
}
|
|
32
|
+
export declare function prepareSelectedSecretBindings(selected: ResolvedSelectedRun, cwd?: string): Promise<SelectedSecretBindings>;
|
|
21
33
|
export declare function executeSelectedLocal(selected: ResolvedSelectedRun, options?: SelectedLocalRunOptions): Promise<{
|
|
22
34
|
exitCode: number;
|
|
23
35
|
stdout: string;
|
|
24
36
|
stderr: string;
|
|
25
37
|
error?: string;
|
|
38
|
+
secretBinding?: {
|
|
39
|
+
schema: "hasna.skills-secret-bindings.v1";
|
|
40
|
+
selection: Pick<ResolvedSkillSelection, "slug" | "version" | "bundleDigest" | "workspaceId" | "authority" | "profileRevision"> & {
|
|
41
|
+
profileId: string;
|
|
42
|
+
};
|
|
43
|
+
consumer: {
|
|
44
|
+
stationId: string;
|
|
45
|
+
workspaceDirectory: string;
|
|
46
|
+
};
|
|
47
|
+
secretsAuthority: string;
|
|
48
|
+
bindings: Record<string, string>;
|
|
49
|
+
} | undefined;
|
|
50
|
+
executionGrant?: {
|
|
51
|
+
policyRevision: string;
|
|
52
|
+
grantId: string;
|
|
53
|
+
} | undefined;
|
|
26
54
|
selection: ResolvedSkillSelection;
|
|
27
55
|
target: "local";
|
|
28
56
|
runtime: any;
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
* — the shared @hasna/contracts ladder — instead of reading an environment
|
|
16
16
|
* variable of its own. See lib/fleet-credentials.ts.
|
|
17
17
|
*/
|
|
18
|
+
export { readExecutionGrantPolicy, saveExecutionGrantPolicy, resolveExecutionGrant } from "../lib/execution-grant-client.js";
|
|
19
|
+
export type { ExecutionGrant, ExecutionGrantPolicy, ExecutionGrantRequest, ResolvedExecutionGrant } from "../lib/execution-grants.js";
|
|
18
20
|
export { HttpProfileClient, createProfileClient, type ProfileClient } from "../lib/profile-client.js";
|
|
21
|
+
export { resolveSelectedRun, executeSelectedLocal, prepareSelectedSecretBindings, type ResolvedSelectedRun, type SelectedLocalRunOptions } from "../lib/selected-run.js";
|
|
22
|
+
export { readSelectedSecretBindings, type SelectedSecretBindings, type SelectedSecretsClient } from "../lib/execution-secrets.js";
|
|
19
23
|
export type { SkillSelection, SkillProfile, ResolvedSkillSelection, ResolvedSkillProfile, StationSkillStateInput, StationSkillState } from "../types/skill-selection.js";
|
|
20
24
|
export { MissingSkillsFleetError, SkillsFleetCredentialError, SKILLS_API_KEY_ENV, SKILLS_API_URL_ENV, SKILLS_APP, SKILLS_LOCAL_OPT_IN_ENV_KEYS, configuredSkillsApiUrl, isSkillsLocalOptIn, noticeLocalSkillsMode, normalizeSkillsApiOrigin, requireSkillsApiOrigin, requireSkillsFleet, resolveSkillsApiOrigin, resolveSkillsFleet, selectsSkillsLocalMode, skillsCredentialFilePath, skillsCredentialFiles, skillsCredentialOrReason, type HostedSkillsFleet, type LocalSkillsFleet, type SkillsFleet, type SkillsFleetErrorCode, type SkillsFleetOptions, } from "../lib/fleet-credentials.js";
|
|
21
25
|
export * from "./server.js";
|