@hasna/skills 0.7.3 → 0.8.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.
Files changed (58) hide show
  1. package/README.md +161 -19
  2. package/bin/index.js +5321 -4850
  3. package/bin/mcp.js +7841 -7538
  4. package/bin/migrate.js +22 -60
  5. package/bin/server.js +73576 -20339
  6. package/bin/worker.js +65159 -19251
  7. package/dist/admin-contract.js +8 -8
  8. package/dist/cli/commands/recurring.d.ts +2 -0
  9. package/dist/index.js +2617 -2747
  10. package/dist/lib/canonical-json.d.ts +8 -0
  11. package/dist/lib/cli-mcp-parity.d.ts +1 -1
  12. package/dist/lib/config.d.ts +3 -23
  13. package/dist/lib/installer.d.ts +1 -1
  14. package/dist/lib/mcp-contracts.d.ts +1 -1
  15. package/dist/lib/portable-skills.d.ts +1 -1
  16. package/dist/lib/recurring-customer.d.ts +29 -0
  17. package/dist/lib/recurring-recovery.d.ts +82 -0
  18. package/dist/lib/recurring-surface.d.ts +252 -0
  19. package/dist/lib/registry-data/index.d.ts +1 -0
  20. package/dist/lib/registry-types.d.ts +2 -1
  21. package/dist/lib/registry.d.ts +2 -12
  22. package/dist/lib/release-dependencies.d.ts +3 -0
  23. package/dist/lib/remote-client.d.ts +13 -0
  24. package/dist/lib/remote-customer-operations.d.ts +1 -0
  25. package/dist/lib/remote-invitations.d.ts +1 -1
  26. package/dist/lib/remote-recurring-contract.d.ts +165 -0
  27. package/dist/lib/remote-recurring.d.ts +95 -0
  28. package/dist/lib/skill-aliases.d.ts +2 -3
  29. package/dist/mcp/mcp-test-client.d.ts +2 -2
  30. package/dist/mcp/remote-recurring-tools.d.ts +2 -0
  31. package/dist/sdk/executor.d.ts +5 -5
  32. package/dist/sdk/index.d.ts +4 -0
  33. package/dist/sdk/index.js +114864 -46432
  34. package/dist/sdk/registry.d.ts +3 -3
  35. package/dist/server/config.d.ts +1 -2
  36. package/dist/server/handlers.d.ts +5 -2
  37. package/dist/server/registry.d.ts +6 -3
  38. package/dist/server/skills-api.d.ts +6 -38
  39. package/dist/storage.js +5 -42
  40. package/package.json +3 -2
  41. package/dist/lib/registry-data/business-marketing.d.ts +0 -2
  42. package/dist/lib/registry-data/communication.d.ts +0 -2
  43. package/dist/lib/registry-data/content-generation.d.ts +0 -2
  44. package/dist/lib/registry-data/data-analysis.d.ts +0 -2
  45. package/dist/lib/registry-data/design-branding.d.ts +0 -2
  46. package/dist/lib/registry-data/development-tools.d.ts +0 -2
  47. package/dist/lib/registry-data/education-learning.d.ts +0 -2
  48. package/dist/lib/registry-data/event-management.d.ts +0 -2
  49. package/dist/lib/registry-data/finance-compliance.d.ts +0 -2
  50. package/dist/lib/registry-data/health-wellness.d.ts +0 -2
  51. package/dist/lib/registry-data/media-processing.d.ts +0 -2
  52. package/dist/lib/registry-data/productivity-organization.d.ts +0 -2
  53. package/dist/lib/registry-data/project-management.d.ts +0 -2
  54. package/dist/lib/registry-data/research-writing.d.ts +0 -2
  55. package/dist/lib/registry-data/science-academic.d.ts +0 -2
  56. package/dist/lib/registry-data/travel-lifestyle.d.ts +0 -2
  57. package/dist/lib/registry-data/web-browser.d.ts +0 -2
  58. package/dist/server/seed-bundled.d.ts +0 -20
@@ -0,0 +1,165 @@
1
+ import { z } from "zod/v4";
2
+ /** Portable versioned wire values only. Eligibility, repricing, freshness, budgets
3
+ * and execution authority are verified by the configured server. */
4
+ export declare const RECURRING_CONTRACT_VERSION: 1;
5
+ export declare const MAX_RECURRING_CREDITS = 2147483647;
6
+ export declare const recurringRequestSchema: z.ZodObject<{
7
+ contractVersion: z.ZodLiteral<1>;
8
+ skill: z.ZodString;
9
+ input: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
10
+ args: z.ZodArray<z.ZodString>;
11
+ runtime: z.ZodObject<{
12
+ timeoutMs: z.ZodNumber;
13
+ maxOutputBytes: z.ZodNumber;
14
+ maxAttempts: z.ZodNumber;
15
+ connectorOperations: z.ZodArray<z.ZodObject<{
16
+ connectorSlug: z.ZodString;
17
+ operationName: z.ZodString;
18
+ }, z.core.$strict>>;
19
+ }, z.core.$strict>;
20
+ everyMinutes: z.ZodNumber;
21
+ startsAt: z.ZodString;
22
+ expiresAt: z.ZodString;
23
+ dispatchGraceSeconds: z.ZodNumber;
24
+ period: z.ZodLiteral<"utc-day">;
25
+ inFlightPolicy: z.ZodLiteral<"finish-authorized-attempt">;
26
+ maxCreditsPerRun: z.ZodNumber;
27
+ maxCreditsPerPeriod: z.ZodNumber;
28
+ maxCreditsTotal: z.ZodNumber;
29
+ maxOccurrencesPerPeriod: z.ZodNumber;
30
+ maxOccurrencesTotal: z.ZodNumber;
31
+ }, z.core.$strict>;
32
+ export type RecurringRequest = z.infer<typeof recurringRequestSchema>;
33
+ export interface RecurringTerms extends RecurringRequest {
34
+ deploymentId: string;
35
+ organizationId: string;
36
+ approvedByUserId: string;
37
+ approvedMembershipId: string;
38
+ policyId: string;
39
+ policyRevision: number;
40
+ skillId: string;
41
+ skillVersionId: string;
42
+ runtimeApprovalDigest: string;
43
+ payloadSha256: string;
44
+ }
45
+ export declare const recurringTermsSchema: z.ZodObject<{
46
+ contractVersion: z.ZodLiteral<1>;
47
+ skill: z.ZodString;
48
+ input: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
49
+ args: z.ZodArray<z.ZodString>;
50
+ runtime: z.ZodObject<{
51
+ timeoutMs: z.ZodNumber;
52
+ maxOutputBytes: z.ZodNumber;
53
+ maxAttempts: z.ZodNumber;
54
+ connectorOperations: z.ZodArray<z.ZodObject<{
55
+ connectorSlug: z.ZodString;
56
+ operationName: z.ZodString;
57
+ }, z.core.$strict>>;
58
+ }, z.core.$strict>;
59
+ everyMinutes: z.ZodNumber;
60
+ startsAt: z.ZodString;
61
+ expiresAt: z.ZodString;
62
+ dispatchGraceSeconds: z.ZodNumber;
63
+ period: z.ZodLiteral<"utc-day">;
64
+ inFlightPolicy: z.ZodLiteral<"finish-authorized-attempt">;
65
+ maxCreditsPerRun: z.ZodNumber;
66
+ maxCreditsPerPeriod: z.ZodNumber;
67
+ maxCreditsTotal: z.ZodNumber;
68
+ maxOccurrencesPerPeriod: z.ZodNumber;
69
+ maxOccurrencesTotal: z.ZodNumber;
70
+ deploymentId: z.ZodString;
71
+ organizationId: z.ZodUUID;
72
+ approvedByUserId: z.ZodUUID;
73
+ approvedMembershipId: z.ZodUUID;
74
+ policyId: z.ZodUUID;
75
+ policyRevision: z.ZodNumber;
76
+ skillId: z.ZodUUID;
77
+ skillVersionId: z.ZodUUID;
78
+ runtimeApprovalDigest: z.ZodString;
79
+ payloadSha256: z.ZodString;
80
+ }, z.core.$strict>;
81
+ export interface RecurringQuote {
82
+ costCredits: number;
83
+ quotedAt: string;
84
+ /** Quote is informational: admission always reprices under authority locks. */
85
+ admissionReprices: true;
86
+ }
87
+ export interface RecurringPreview {
88
+ contractVersion: typeof RECURRING_CONTRACT_VERSION;
89
+ draftId: string;
90
+ terms: RecurringTerms;
91
+ termsSha256: string;
92
+ quote: RecurringQuote;
93
+ approvalDeadline: string;
94
+ firstDueInstants: string[];
95
+ firstPeriod: {
96
+ startsAt: string;
97
+ endsAt: string;
98
+ };
99
+ additionalBudget: true;
100
+ }
101
+ export declare const recurringActivationSchema: z.ZodObject<{
102
+ contractVersion: z.ZodLiteral<1>;
103
+ acceptedTermsSha256: z.ZodString;
104
+ acceptance: z.ZodLiteral<"authorize-recurring-credit-use">;
105
+ idempotencyKey: z.ZodString;
106
+ }, z.core.$strict>;
107
+ export type RecurringActivation = z.infer<typeof recurringActivationSchema>;
108
+ export interface RecurringBudget {
109
+ reservedCredits: number;
110
+ settledCredits: number;
111
+ admittedOccurrences: number;
112
+ }
113
+ export interface RecurringConsentView {
114
+ contractVersion: typeof RECURRING_CONTRACT_VERSION;
115
+ consentId: string;
116
+ scheduleId: string;
117
+ terms: RecurringTerms;
118
+ termsSha256: string;
119
+ state: "active" | "revoked" | "expired";
120
+ activatedAt: string;
121
+ revokedAt: string | null;
122
+ total: RecurringBudget;
123
+ currentPeriod: (RecurringBudget & {
124
+ startsAt: string;
125
+ endsAt: string;
126
+ }) | null;
127
+ nextDueAt: string | null;
128
+ }
129
+ export interface RecurringActivationResult {
130
+ replayed: boolean;
131
+ consent: RecurringConsentView;
132
+ }
133
+ export interface RecurringPage<T> {
134
+ contractVersion: typeof RECURRING_CONTRACT_VERSION;
135
+ items: T[];
136
+ nextCursor: string | null;
137
+ }
138
+ export type RecurringRefusal = "consent-inactive" | "authority-revoked" | "policy-disabled" | "policy-changed" | "skill-changed" | "quote-unavailable" | "per-run-ceiling" | "period-ceiling" | "total-ceiling" | "period-count" | "total-count" | "insufficient-credits" | "input-quota" | "runtime-unavailable";
139
+ export interface RecurringOccurrenceView {
140
+ occurrenceId: string;
141
+ scheduleId: string;
142
+ dueAt: string;
143
+ periodStartsAt: string;
144
+ periodEndsAt: string;
145
+ outcome: "admitted" | "skipped" | "refused";
146
+ reason: RecurringRefusal | "dispatch-grace-elapsed" | null;
147
+ runId: string | null;
148
+ quotedCredits: number | null;
149
+ allocationState: "reserved" | "captured" | "released" | null;
150
+ }
151
+ export interface RecurringRevocation {
152
+ contractVersion: typeof RECURRING_CONTRACT_VERSION;
153
+ consentId: string;
154
+ revokedAt: string;
155
+ /** Bounded snapshot; separate paginated occurrences contains every run. */
156
+ authorizedRuns: {
157
+ runId: string;
158
+ attempt: number;
159
+ reservedCredits: number;
160
+ }[];
161
+ authorizedRunCount: number;
162
+ residualReservedCredits: number;
163
+ inFlightPolicy: "finish-authorized-attempt";
164
+ cancellationIsSeparate: true;
165
+ }
@@ -0,0 +1,95 @@
1
+ import { type RecurringRequest, type RecurringActivation, type RecurringPreview, type RecurringConsentView, type RecurringActivationResult, type RecurringPage, type RecurringOccurrenceView, type RecurringRevocation } from "./remote-recurring-contract.js";
2
+ import type { RemoteWorkspaceIdentity } from "./remote-workspace-selection.js";
3
+ export * from "./remote-recurring-contract.js";
4
+ export interface RecurringCapability {
5
+ contractVersion: 1;
6
+ available: boolean;
7
+ }
8
+ export type RecurringListOptions = Readonly<{
9
+ limit?: number;
10
+ cursor?: string;
11
+ }>;
12
+ export type RecurringAction = "preview" | "draft" | "activate" | "list" | "get" | "occurrences" | "revoke";
13
+ export type RecurringInputs = {
14
+ preview: RecurringRequest;
15
+ draft: {
16
+ draftId: string;
17
+ };
18
+ activate: {
19
+ draftId: string;
20
+ approval: RecurringActivation;
21
+ };
22
+ list: RecurringListOptions;
23
+ get: {
24
+ consentId: string;
25
+ };
26
+ occurrences: RecurringListOptions & {
27
+ consentId: string;
28
+ };
29
+ revoke: {
30
+ consentId: string;
31
+ };
32
+ };
33
+ export type RecurringResults = {
34
+ preview: RecurringPreview;
35
+ draft: RecurringPreview | null;
36
+ activate: RecurringActivationResult;
37
+ list: RecurringPage<RecurringConsentView>;
38
+ get: RecurringConsentView | null;
39
+ occurrences: RecurringPage<RecurringOccurrenceView>;
40
+ revoke: RecurringRevocation;
41
+ };
42
+ export declare class RecurringInputError extends Error {
43
+ readonly code = "RECURRING_INPUT_INVALID";
44
+ constructor();
45
+ }
46
+ export declare class RemoteRecurringUnavailableError extends Error {
47
+ readonly code = "RECURRING_UNAVAILABLE";
48
+ constructor();
49
+ }
50
+ export declare class RemoteRecurringReadError extends Error {
51
+ readonly code = "RECURRING_READ_FAILED";
52
+ constructor();
53
+ }
54
+ export declare class RemoteRecurringUnconfirmedError extends Error {
55
+ readonly code = "RECURRING_OUTCOME_UNKNOWN";
56
+ readonly outcomeUnknown = true;
57
+ constructor();
58
+ }
59
+ declare const failures: {
60
+ readonly RECURRING_INVALID_REQUEST: readonly [400, "Recurring parameters were refused."];
61
+ readonly RECURRING_INVALID_CURSOR: readonly [400, "Recurring page cursor was refused."];
62
+ readonly RECURRING_BODY_TOO_LARGE: readonly [413, "Recurring input exceeds the server limit."];
63
+ readonly RECURRING_UNAUTHENTICATED: readonly [401, "A current authenticated membership is required."];
64
+ readonly RECURRING_HUMAN_APPROVAL_REQUIRED: readonly [403, "A fresh human sign-in is required to activate recurring consent."];
65
+ readonly RECURRING_IMPERSONATION_DENIED: readonly [403, "Recurring changes are unavailable while impersonating."];
66
+ readonly RECURRING_AUTHORITY_REFUSED: readonly [403, "Current recurring authority was refused."];
67
+ readonly RECURRING_DEPLOYMENT_MISMATCH: readonly [403, "The recurring draft belongs to another deployment."];
68
+ readonly RECURRING_SKILL_CHANGED: readonly [409, "The recurring skill has changed."];
69
+ readonly RECURRING_TERMS_UNAVAILABLE: readonly [409, "The original recurring terms are unavailable."];
70
+ readonly RECURRING_QUOTE_EXCEEDS_CEILING: readonly [409, "The current quote exceeds the approved recurring ceiling."];
71
+ readonly RECURRING_NOT_FOUND: readonly [404, "Recurring state is unavailable for this account."];
72
+ readonly RECURRING_METHOD_NOT_ALLOWED: readonly [405, "The recurring operation is unsupported."];
73
+ readonly RECURRING_UNAVAILABLE: readonly [503, "Recurring operations are unavailable on this server."];
74
+ readonly INSUFFICIENT_SCOPE: readonly [403, "The credential lacks the required recurring scope."];
75
+ readonly RATE_LIMITED: readonly [429, "The recurring request limit was reached. Wait before another explicit request."];
76
+ };
77
+ export type RemoteRecurringErrorCode = keyof typeof failures;
78
+ export declare class RemoteRecurringError extends Error {
79
+ readonly code: RemoteRecurringErrorCode;
80
+ readonly status: number;
81
+ constructor(code: RemoteRecurringErrorCode);
82
+ }
83
+ export declare function recurringFailure(value: unknown, status: number): RemoteRecurringErrorCode | null;
84
+ /** Snapshot before any await. Validation does not substitute for server policy. */
85
+ export declare function recurringInput<A extends RecurringAction>(action: A, raw: RecurringInputs[A]): RecurringInputs[A];
86
+ export declare function parseRecurringCapability(value: unknown): RecurringCapability | undefined;
87
+ export declare function assertRecurringCapability(value: unknown, action: RecurringAction): void;
88
+ export declare function recurringRequest<A extends RecurringAction>(action: A, input: RecurringInputs[A]): {
89
+ path: string;
90
+ read: boolean;
91
+ method: string;
92
+ body: string | undefined;
93
+ };
94
+ /** Projects known response fields. Immutable terms remain exact and hash-bound. */
95
+ export declare function parseRecurringResult<A extends RecurringAction>(action: A, value: unknown, input: RecurringInputs[A], identity: RemoteWorkspaceIdentity): RecurringResults[A];
@@ -1,6 +1,5 @@
1
- export declare const SKILL_ALIASES: {
2
- readonly "create-blog-article": "blog-article";
3
- };
1
+ /** @deprecated Aliases belong to an account's selected profile, never the package. */
2
+ export declare const SKILL_ALIASES: Readonly<Record<string, string>>;
4
3
  export type SkillAlias = keyof typeof SKILL_ALIASES;
5
4
  export declare function normalizeSkillSlug(name: string): string;
6
5
  export declare function resolveSkillAlias(name: string): string;
@@ -1,5 +1,5 @@
1
- export declare const EXPECTED_ALL_SKILL_COUNT: number;
2
- export declare const EXPECTED_BASIC_SKILL_COUNT: 8;
1
+ export declare const EXPECTED_ALL_SKILL_COUNT: 12;
2
+ export declare const EXPECTED_BASIC_SKILL_COUNT: 12;
3
3
  /**
4
4
  * Helper class to communicate with the MCP server over stdio.
5
5
  */
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerRecurringTools(server: McpServer): void;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Executor seam: what actually runs a claimed skill run.
2
+ * Compatibility seam for historical unversioned run records.
3
3
  *
4
- * The interface is the contract an embedder supplies an executor against. The current
5
- * implementation is the provider-free deterministic handler the shipped worker runs
6
- * (src/server/handlers.ts) — same logs, same artifacts, same terminal transitions.
4
+ * Embedders may supply their own implementation of the interface. The legacy
5
+ * implementation only drains old records to a fenced refusal; versioned bundle
6
+ * execution uses the managed runtime and never resolves an embedded skill name.
7
7
  */
8
8
  import { ArtifactStorage } from "../server/artifact-storage.js";
9
9
  import { executeRun } from "../server/handlers.js";
@@ -12,6 +12,6 @@ import type { ServerRunRecord, SkillsProductStore } from "../server/types.js";
12
12
  export interface RunExecutor {
13
13
  execute(store: SkillsProductStore, run: ServerRunRecord, storage?: ArtifactStorage): Promise<ServerRunRecord>;
14
14
  }
15
- /** Current implementation: the shipped deterministic handler, unchanged. */
15
+ /** @deprecated Drains legacy records with LEGACY_EXECUTION_RETIRED; executes no skill. */
16
16
  export declare const localRunExecutor: RunExecutor;
17
17
  export { executeRun };
@@ -33,6 +33,10 @@ export * from "./spend.js";
33
33
  export * from "./offline.js";
34
34
  export * from "./execution/index.js";
35
35
  export { RemoteSkillsClient, createRemoteSkillsClient, RemoteRequestError, RemoteRouteUnsupportedError, RemoteCapabilityUnavailableError, RemoteQuoteUnavailableError, RemoteWorkspaceMemberError } from "../lib/remote-client.js";
36
+ export * from "../lib/remote-recurring-contract.js";
37
+ export { RecurringInputError, RemoteRecurringError, RemoteRecurringUnavailableError, RemoteRecurringReadError, RemoteRecurringUnconfirmedError } from "../lib/remote-recurring.js";
38
+ export type { RecurringCapability, RecurringListOptions, RemoteRecurringErrorCode } from "../lib/remote-recurring.js";
39
+ export { canonicalJson, canonicalJsonSha256 } from "../lib/canonical-json.js";
36
40
  export type { RemoteQuoteUnavailableCode } from "../lib/remote-client.js";
37
41
  export { RemoteCreditApprovalError, type RemoteRunApproval, type RemoteRunQuote, type RemoteCreditPack } from "../lib/remote-account.js";
38
42
  export { type RemoteInputFile, type RemoteInputFileDescriptor } from "../lib/remote-files.js";