@hasna/skills 0.2.1 → 0.4.0

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.
Files changed (37) hide show
  1. package/README.md +192 -44
  2. package/bin/index.js +15778 -24369
  3. package/bin/mcp.js +4802 -13678
  4. package/bin/migrate.js +5 -0
  5. package/bin/server.js +380 -214
  6. package/bin/worker.js +365 -199
  7. package/dist/admin-contract.d.ts +5861 -916
  8. package/dist/admin-contract.js +3611 -13914
  9. package/dist/cli/cli.test-utils.d.ts +14 -0
  10. package/dist/cli/commands/remote-account.d.ts +7 -0
  11. package/dist/index.d.ts +3 -0
  12. package/dist/index.js +5543 -14354
  13. package/dist/lib/api-url.d.ts +32 -23
  14. package/dist/lib/auth-store.d.ts +111 -42
  15. package/dist/lib/config.d.ts +19 -21
  16. package/dist/lib/feedback.d.ts +8 -3
  17. package/dist/lib/fleet-credentials.d.ts +252 -0
  18. package/dist/lib/instance-credentials-race.fixture.d.ts +1 -0
  19. package/dist/lib/instance-credentials.d.ts +13 -0
  20. package/dist/lib/mcp-contracts.d.ts +4 -0
  21. package/dist/lib/portable-skills-files.d.ts +4 -0
  22. package/dist/lib/portable-skills-types.d.ts +2 -0
  23. package/dist/lib/remote-account.d.ts +42 -0
  24. package/dist/lib/remote-auth.d.ts +32 -0
  25. package/dist/lib/remote-client.d.ts +75 -10
  26. package/dist/lib/remote-customer-operations.d.ts +106 -0
  27. package/dist/lib/remote-files.d.ts +21 -0
  28. package/dist/lib/remote-registry.d.ts +31 -11
  29. package/dist/lib/run-routing.d.ts +7 -4
  30. package/dist/lib/run-state.d.ts +3 -0
  31. package/dist/lib/vendor-host-policy.d.ts +31 -0
  32. package/dist/mcp/remote-customer-tools.d.ts +2 -0
  33. package/dist/sdk/index.d.ts +10 -0
  34. package/dist/sdk/index.js +6251 -14621
  35. package/dist/sdk/runs.d.ts +101 -19
  36. package/dist/storage.js +9 -14
  37. package/package.json +4 -3
@@ -38,7 +38,23 @@ export declare const runAdmissionSchema: z.ZodObject<{
38
38
  skill: z.ZodString;
39
39
  status: z.ZodLiteral<"admitted">;
40
40
  createdAt: z.ZodString;
41
- }, z.core.$strip>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ status: "admitted";
43
+ createdAt: string;
44
+ skill: string;
45
+ contractVersion: 1;
46
+ runId: string;
47
+ leaseGeneration: number;
48
+ attemptId: string;
49
+ }, {
50
+ status: "admitted";
51
+ createdAt: string;
52
+ skill: string;
53
+ contractVersion: 1;
54
+ runId: string;
55
+ leaseGeneration: number;
56
+ attemptId: string;
57
+ }>;
42
58
  export type RunAdmission = z.infer<typeof runAdmissionSchema>;
43
59
  /** Lease: a worker has claimed the run. */
44
60
  export declare const runLeaseSchema: z.ZodObject<{
@@ -48,7 +64,21 @@ export declare const runLeaseSchema: z.ZodObject<{
48
64
  leaseGeneration: z.ZodNumber;
49
65
  workerId: z.ZodString;
50
66
  status: z.ZodLiteral<"leased">;
51
- }, z.core.$strip>;
67
+ }, "strip", z.ZodTypeAny, {
68
+ status: "leased";
69
+ contractVersion: 1;
70
+ runId: string;
71
+ leaseGeneration: number;
72
+ attemptId: string;
73
+ workerId: string;
74
+ }, {
75
+ status: "leased";
76
+ contractVersion: 1;
77
+ runId: string;
78
+ leaseGeneration: number;
79
+ attemptId: string;
80
+ workerId: string;
81
+ }>;
52
82
  export type RunLease = z.infer<typeof runLeaseSchema>;
53
83
  /** Terminal: the run reached a final state. */
54
84
  export declare const runTerminalSchema: z.ZodObject<{
@@ -57,17 +87,28 @@ export declare const runTerminalSchema: z.ZodObject<{
57
87
  attemptId: z.ZodString;
58
88
  leaseGeneration: z.ZodNumber;
59
89
  skill: z.ZodString;
60
- status: z.ZodEnum<{
61
- cancelled: "cancelled";
62
- failed: "failed";
63
- succeeded: "succeeded";
64
- expired: "expired";
65
- }>;
90
+ status: z.ZodEnum<["succeeded", "failed", "cancelled", "expired"]>;
66
91
  completedAt: z.ZodString;
67
- }, z.core.$strip>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ status: "cancelled" | "failed" | "expired" | "succeeded";
94
+ skill: string;
95
+ completedAt: string;
96
+ contractVersion: 1;
97
+ runId: string;
98
+ leaseGeneration: number;
99
+ attemptId: string;
100
+ }, {
101
+ status: "cancelled" | "failed" | "expired" | "succeeded";
102
+ skill: string;
103
+ completedAt: string;
104
+ contractVersion: 1;
105
+ runId: string;
106
+ leaseGeneration: number;
107
+ attemptId: string;
108
+ }>;
68
109
  export type RunTerminal = z.infer<typeof runTerminalSchema>;
69
110
  /** Any single protocol message, discriminated by `status`. */
70
- export declare const runProtocolSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
111
+ export declare const runProtocolSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
71
112
  contractVersion: z.ZodLiteral<1>;
72
113
  runId: z.ZodString;
73
114
  attemptId: z.ZodString;
@@ -75,27 +116,68 @@ export declare const runProtocolSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
75
116
  skill: z.ZodString;
76
117
  status: z.ZodLiteral<"admitted">;
77
118
  createdAt: z.ZodString;
78
- }, z.core.$strip>, z.ZodObject<{
119
+ }, "strip", z.ZodTypeAny, {
120
+ status: "admitted";
121
+ createdAt: string;
122
+ skill: string;
123
+ contractVersion: 1;
124
+ runId: string;
125
+ leaseGeneration: number;
126
+ attemptId: string;
127
+ }, {
128
+ status: "admitted";
129
+ createdAt: string;
130
+ skill: string;
131
+ contractVersion: 1;
132
+ runId: string;
133
+ leaseGeneration: number;
134
+ attemptId: string;
135
+ }>, z.ZodObject<{
79
136
  contractVersion: z.ZodLiteral<1>;
80
137
  runId: z.ZodString;
81
138
  attemptId: z.ZodString;
82
139
  leaseGeneration: z.ZodNumber;
83
140
  workerId: z.ZodString;
84
141
  status: z.ZodLiteral<"leased">;
85
- }, z.core.$strip>, z.ZodObject<{
142
+ }, "strip", z.ZodTypeAny, {
143
+ status: "leased";
144
+ contractVersion: 1;
145
+ runId: string;
146
+ leaseGeneration: number;
147
+ attemptId: string;
148
+ workerId: string;
149
+ }, {
150
+ status: "leased";
151
+ contractVersion: 1;
152
+ runId: string;
153
+ leaseGeneration: number;
154
+ attemptId: string;
155
+ workerId: string;
156
+ }>, z.ZodObject<{
86
157
  contractVersion: z.ZodLiteral<1>;
87
158
  runId: z.ZodString;
88
159
  attemptId: z.ZodString;
89
160
  leaseGeneration: z.ZodNumber;
90
161
  skill: z.ZodString;
91
- status: z.ZodEnum<{
92
- cancelled: "cancelled";
93
- failed: "failed";
94
- succeeded: "succeeded";
95
- expired: "expired";
96
- }>;
162
+ status: z.ZodEnum<["succeeded", "failed", "cancelled", "expired"]>;
97
163
  completedAt: z.ZodString;
98
- }, z.core.$strip>], "status">;
164
+ }, "strip", z.ZodTypeAny, {
165
+ status: "cancelled" | "failed" | "expired" | "succeeded";
166
+ skill: string;
167
+ completedAt: string;
168
+ contractVersion: 1;
169
+ runId: string;
170
+ leaseGeneration: number;
171
+ attemptId: string;
172
+ }, {
173
+ status: "cancelled" | "failed" | "expired" | "succeeded";
174
+ skill: string;
175
+ completedAt: string;
176
+ contractVersion: 1;
177
+ runId: string;
178
+ leaseGeneration: number;
179
+ attemptId: string;
180
+ }>]>;
99
181
  export type RunProtocolMessage = z.infer<typeof runProtocolSchema>;
100
182
  /** Map the store's status vocabulary onto the protocol lifecycle. */
101
183
  export declare function protocolStateOf(status: ServerRunStatus): RunProtocolState;
package/dist/storage.js CHANGED
@@ -65,7 +65,12 @@ import { join as join2, dirname } from "path";
65
65
  // src/lib/retired-settings.ts
66
66
  var RETIRED_ENV_SUFFIXES = ["_STORAGE_MODE", "_DEPLOYMENT_MODE", "_CLOUD_MODE"];
67
67
  var RETIRED_CONFIG_KEYS = {
68
- mode: "apiUrl"
68
+ mode: "a configured API origin",
69
+ apiUrl: "skills setup --api-url <origin>"
70
+ };
71
+ var RETIRED_CONFIG_KEY_REASONS = {
72
+ mode: "Deployment modes were removed: a Skills client either resolves a credential " + "or it does not, and that is the whole of it.",
73
+ apiUrl: "The service address is no longer kept in this app's config file: it is read from " + "HASNA_SKILLS_API_URL, then the macOS Keychain item hasna.credentials.skills.api-url, " + "then ~/.hasna/skills/config/credentials, then the fleet gateway."
69
74
  };
70
75
 
71
76
  class RetiredSettingError extends Error {
@@ -104,7 +109,7 @@ function assertNoRetiredConfigKeys(config, source) {
104
109
  for (const [key, replacement] of Object.entries(RETIRED_CONFIG_KEYS)) {
105
110
  if (!(key in config))
106
111
  continue;
107
- throw new RetiredSettingError(key, `${source}: "${key}" is no longer a configuration key. ` + "Deployment modes were removed: a Skills client either has an API origin " + "configured or it does not, and that is the whole of it. " + `Use "${replacement}" instead (skills config set ${replacement} <origin>), and ` + `remove the old key with: skills config unset ${key}. ` + "Refused rather than ignored, because silently dropping it would leave an " + "operator believing they had pointed this install at a server.");
112
+ throw new RetiredSettingError(key, `${source}: "${key}" is no longer a configuration key. ` + `${RETIRED_CONFIG_KEY_REASONS[key] ?? ""} ` + `Use ${replacement} instead, and remove the old key with: skills config unset ${key}. ` + "Refused rather than ignored, because silently dropping it would leave an " + "operator believing they had pointed this install at a server.");
108
113
  }
109
114
  }
110
115
 
@@ -232,7 +237,7 @@ var ENUM_KEYS = {
232
237
  defaultScope: ["global", "project"],
233
238
  format: ["compact", "json", "csv"]
234
239
  };
235
- var STRING_KEYS = ["apiUrl", "extensionsDir"];
240
+ var STRING_KEYS = ["extensionsDir"];
236
241
  function validKeys() {
237
242
  return [...Object.keys(ENUM_KEYS), ...STRING_KEYS];
238
243
  }
@@ -263,16 +268,6 @@ function normalizeConfigValue(key, value) {
263
268
  const allowed = allowedValues(key);
264
269
  if (allowed)
265
270
  return allowed.includes(value) ? value : undefined;
266
- if (key === "apiUrl") {
267
- try {
268
- const url = new URL(value);
269
- if (url.protocol !== "http:" && url.protocol !== "https:")
270
- return;
271
- return value.replace(/\/+$/, "");
272
- } catch {
273
- return;
274
- }
275
- }
276
271
  if (key === "extensionsDir")
277
272
  return value.trim() ? value : undefined;
278
273
  return;
@@ -342,7 +337,7 @@ function saveConfig(key, value, scope = "project") {
342
337
  const normalized = normalizeConfigValue(key, value);
343
338
  if (normalized === undefined) {
344
339
  const allowed = allowedValues(key);
345
- throw new Error(allowed ? `Invalid value '${value}' for ${key}. Allowed: ${allowed.join(", ")}` : `Invalid value '${value}' for ${key}. Expected ${key === "apiUrl" ? "an http(s) URL" : "a non-empty path"}`);
340
+ throw new Error(allowed ? `Invalid value '${value}' for ${key}. Allowed: ${allowed.join(", ")}` : `Invalid value '${value}' for ${key}. Expected a non-empty path`);
346
341
  }
347
342
  const filePath = getConfigPath(scope);
348
343
  let existing = {};
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@hasna/skills",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Skills library for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "skills": "bin/index.js",
8
8
  "skills-mcp": "bin/mcp.js",
9
+ "skills-serve": "bin/server.js",
9
10
  "skills-server": "bin/server.js",
10
11
  "skills-worker": "bin/worker.js",
11
12
  "skills-migrate": "bin/migrate.js"
@@ -58,8 +59,7 @@
58
59
  "verify:release": "bun run scripts/release-guard.ts",
59
60
  "prepare": "bun run build:js",
60
61
  "prepack": "bun run build && bun run verify:release",
61
- "prepublishOnly": "bun run typecheck && bun run test",
62
- "postinstall": "mkdir -p $HOME/.hasna/skills/custom 2>/dev/null || true"
62
+ "prepublishOnly": "bun run typecheck && bun run test"
63
63
  },
64
64
  "keywords": [
65
65
  "skills",
@@ -91,6 +91,7 @@
91
91
  "dependencies": {
92
92
  "@aws-sdk/client-ecs": "^3.1079.0",
93
93
  "@aws-sdk/client-s3": "^3.1079.0",
94
+ "@hasna/contracts": "1.0.1",
94
95
  "@hasna/events": "0.1.16",
95
96
  "@modelcontextprotocol/sdk": "^1.26.0",
96
97
  "chalk": "^5.3.0",