@hasna/skills 0.8.2 → 0.8.4
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 +70 -2
- package/bin/index.js +588 -285
- package/bin/mcp.js +255 -109
- package/bin/migrate.js +82 -24
- package/bin/server.js +1222 -430
- package/bin/worker.js +395 -87
- package/dist/cli/commands/grants.d.ts +2 -0
- package/dist/index.js +3 -3
- package/dist/lib/execution-grant-client.d.ts +5 -0
- package/dist/lib/execution-grants.d.ts +49 -0
- package/dist/lib/selected-manifest.d.ts +6 -0
- package/dist/lib/selected-run.d.ts +9 -0
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +9205 -8724
- 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,29 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import type { ApiPrincipal } from "./types.js";
|
|
3
|
+
import type { ExecutionGrant, ExecutionGrantPolicy } from "../lib/execution-grants.js";
|
|
4
|
+
export interface ExecutionGrantStore {
|
|
5
|
+
get(principal: ApiPrincipal, profileId: string, revision?: string): Promise<ExecutionGrantPolicy | null>;
|
|
6
|
+
/** Atomically change the current revision and append immutable history. Null is a CAS conflict. */
|
|
7
|
+
save(principal: ApiPrincipal, profileId: string, grants: ExecutionGrant[], expected: string | null): Promise<ExecutionGrantPolicy | null>;
|
|
8
|
+
}
|
|
9
|
+
type Row = Record<string, unknown>;
|
|
10
|
+
export declare class MemoryExecutionGrantStore implements ExecutionGrantStore {
|
|
11
|
+
private current;
|
|
12
|
+
private history;
|
|
13
|
+
get(p: ApiPrincipal, id: string, revision?: string): Promise<ExecutionGrantPolicy | null>;
|
|
14
|
+
save(p: ApiPrincipal, id: string, grants: ExecutionGrant[], expected: string | null): Promise<ExecutionGrantPolicy | null>;
|
|
15
|
+
}
|
|
16
|
+
export declare class SqliteExecutionGrantStore implements ExecutionGrantStore {
|
|
17
|
+
private db;
|
|
18
|
+
constructor(db: Database);
|
|
19
|
+
get(p: ApiPrincipal, id: string, revision?: string): Promise<ExecutionGrantPolicy | null>;
|
|
20
|
+
save(p: ApiPrincipal, id: string, grants: ExecutionGrant[], expected: string | null): Promise<ExecutionGrantPolicy | null>;
|
|
21
|
+
}
|
|
22
|
+
type Sql = (strings: TemplateStringsArray, ...values: unknown[]) => Promise<Row[]>;
|
|
23
|
+
export declare class PostgresExecutionGrantStore implements ExecutionGrantStore {
|
|
24
|
+
private sql;
|
|
25
|
+
constructor(sql: Sql);
|
|
26
|
+
get(p: ApiPrincipal, id: string, revision?: string): Promise<ExecutionGrantPolicy | null>;
|
|
27
|
+
save(p: ApiPrincipal, id: string, grants: ExecutionGrant[], expected: string | null): Promise<ExecutionGrantPolicy | null>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ApiPrincipal, SkillsProductStore } from "./types.js";
|
|
2
|
+
import type { SkillsServerConfig } from "./config.js";
|
|
3
|
+
import type { ArtifactStorage } from "./artifact-storage.js";
|
|
4
|
+
export declare function handleExecutionGrantApi(store: SkillsProductStore, principal: ApiPrincipal, request: Request, parts: string[], config: SkillsServerConfig, artifacts: ArtifactStorage): Promise<Response | null>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SqliteExecutionGrantStore } from "./execution-grant-store.js";
|
|
1
2
|
/**
|
|
2
3
|
* SQLite implementation of SkillsProductStore.
|
|
3
4
|
*
|
|
@@ -32,6 +33,7 @@ export interface SqliteStoreOptions {
|
|
|
32
33
|
}
|
|
33
34
|
export declare class SqliteSkillsStore implements SkillsProductStore {
|
|
34
35
|
get selectionStore(): SqliteSkillSelectionStore;
|
|
36
|
+
get executionGrantStore(): SqliteExecutionGrantStore;
|
|
35
37
|
readonly backend: StoreBackendInfo;
|
|
36
38
|
private db;
|
|
37
39
|
private closed;
|
package/dist/server/store.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MemoryExecutionGrantStore, PostgresExecutionGrantStore } from "./execution-grant-store.js";
|
|
1
2
|
import { MemorySkillSelectionStore, PostgresSkillSelectionStore } from "./selection-store.js";
|
|
2
3
|
import type { ApiPrincipal, ClaimRunInput, CreateRunInput, PublishSkillInput, RunTransitionPatch, ServerArtifact, ServerPin, ServerRunLog, ServerRunRecord, ServerSkillBundle, ServerSkillRecord, ServerSkillVersion, SkillsProductStore, StoreBackendInfo, UpdateSkillPatch } from "./types.js";
|
|
3
4
|
import { type SqliteStoreOptions } from "./sqlite-store.js";
|
|
@@ -25,6 +26,7 @@ export interface StoreOptions {
|
|
|
25
26
|
export declare function createStore(options?: StoreOptions): Promise<SkillsProductStore>;
|
|
26
27
|
export declare class MemorySkillsStore implements SkillsProductStore {
|
|
27
28
|
readonly selectionStore: MemorySkillSelectionStore;
|
|
29
|
+
readonly executionGrantStore: MemoryExecutionGrantStore;
|
|
28
30
|
readonly backend: StoreBackendInfo;
|
|
29
31
|
private apiKeys;
|
|
30
32
|
private runs;
|
|
@@ -90,6 +92,7 @@ export declare class MemorySkillsStore implements SkillsProductStore {
|
|
|
90
92
|
}
|
|
91
93
|
export declare class PostgresSkillsStore implements SkillsProductStore {
|
|
92
94
|
get selectionStore(): PostgresSkillSelectionStore;
|
|
95
|
+
get executionGrantStore(): PostgresExecutionGrantStore;
|
|
93
96
|
readonly backend: StoreBackendInfo;
|
|
94
97
|
private sql;
|
|
95
98
|
constructor(databaseUrl: string);
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OwnedBytes } from "../lib/skill-bundle.js";
|
|
2
|
+
import type { ExecutionGrantStore } from "./execution-grant-store.js";
|
|
2
3
|
import type { SkillSelectionStore } from "./selection-store.js";
|
|
3
4
|
export declare const SERVER_RUN_STATUSES: readonly ["queued", "waiting_for_approval", "running", "succeeded", "failed", "cancel_requested", "cancelled", "retrying", "expired", "refunded"];
|
|
4
5
|
export type ServerRunStatus = (typeof SERVER_RUN_STATUSES)[number];
|
|
@@ -300,6 +301,7 @@ export interface SkillsProductStore {
|
|
|
300
301
|
readonly backend?: StoreBackendInfo;
|
|
301
302
|
/** Optional for third-party stores; profile APIs fail closed when absent. */
|
|
302
303
|
readonly selectionStore?: SkillSelectionStore;
|
|
304
|
+
readonly executionGrantStore?: ExecutionGrantStore;
|
|
303
305
|
/** Release connections and file handles. Optional; not every backend holds any. */
|
|
304
306
|
close?(): Promise<void>;
|
|
305
307
|
/**
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- Explicit org predicates fence API reads/writes; there is no context-less worker writer.
|
|
2
|
+
CREATE TABLE IF NOT EXISTS skills_execution_grants (
|
|
3
|
+
org_id text NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
|
4
|
+
profile_id text NOT NULL,
|
|
5
|
+
revision text NOT NULL,
|
|
6
|
+
document_json jsonb NOT NULL,
|
|
7
|
+
PRIMARY KEY (org_id, profile_id)
|
|
8
|
+
);
|
|
9
|
+
CREATE TABLE IF NOT EXISTS skills_execution_grant_revisions (
|
|
10
|
+
org_id text NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
|
11
|
+
profile_id text NOT NULL,
|
|
12
|
+
revision text NOT NULL,
|
|
13
|
+
document_json jsonb NOT NULL,
|
|
14
|
+
PRIMARY KEY (org_id, profile_id, revision)
|
|
15
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- Current policy and immutable history are changed in one transaction.
|
|
2
|
+
CREATE TABLE IF NOT EXISTS skills_execution_grants (
|
|
3
|
+
org_id text NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
|
4
|
+
profile_id text NOT NULL,
|
|
5
|
+
revision text NOT NULL,
|
|
6
|
+
document_json text NOT NULL,
|
|
7
|
+
PRIMARY KEY (org_id, profile_id)
|
|
8
|
+
);
|
|
9
|
+
CREATE TABLE IF NOT EXISTS skills_execution_grant_revisions (
|
|
10
|
+
org_id text NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
|
11
|
+
profile_id text NOT NULL,
|
|
12
|
+
revision text NOT NULL,
|
|
13
|
+
document_json text NOT NULL,
|
|
14
|
+
PRIMARY KEY (org_id, profile_id, revision)
|
|
15
|
+
);
|