@hasna/skills 0.8.0 → 0.8.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.
package/README.md CHANGED
@@ -324,6 +324,48 @@ are explicitly changed or a new session starts.
324
324
 
325
325
  ## Executable skills
326
326
 
327
+ For a selected local executable that declares `runtime.env`, prepare a binding
328
+ template using the configured Skills and Secrets clients:
329
+
330
+ ```bash
331
+ skills run --target local --selection-profile default \
332
+ --secret-bindings-template --json your-skill@1.0.0 > bindings.json
333
+ # Fill each empty entry in bindings with its reviewed vault key, never its value.
334
+ skills run --target local --selection-profile default \
335
+ --secret-bindings ./bindings.json --input '{"requested":"work"}' \
336
+ --json your-skill@1.0.0
337
+ ```
338
+
339
+ The template contains no credential values and does not execute the skill or
340
+ read the declared secrets. Keep the reviewed file in your private configuration,
341
+ outside the skill bundle and agent discovery directories. It uses
342
+ `hasna.skills-secret-bindings.v1` and binds the exact Skills authority, workspace,
343
+ profile ID and revision, canonical skill name, version and bundle digest, plus
344
+ the current station ID (`HASNA_STATION`, otherwise the hostname), canonical
345
+ working directory and independently configured Secrets `/v1` authority. Its
346
+ `bindings` object maps each declared environment name to one vault key. Changing
347
+ any bound field requires reviewing a fresh template. These are explicit local
348
+ execution grants; selection sync does not distribute or implicitly approve them.
349
+
350
+ The CLI validates the complete binding before fetching values through
351
+ `@hasna/secrets`. It resolves current values for each run, checks returned keys
352
+ and expiry, and injects only the declared variables into the child process.
353
+ Missing, extra, stale or mismatched bindings refuse execution; a failing vault
354
+ read never falls back to an ambient value or a local vault. Wrapping `skills run`
355
+ in `secrets exec` alone does not bind a declared variable. Runtime controls such
356
+ as `PATH`, `NODE_OPTIONS` and `SKILLS_INPUT_JSON` cannot be credential names.
357
+ Bindings require an explicit local target and a fresh API selection; they cannot
358
+ be used with cached, cloud or legacy remote execution. No S3 deployment is required.
359
+
360
+ Run receipts retain references and scope, never resolved values or captured
361
+ output. Returned child output redacts literal, JSON-escaped, base64 and URL-encoded
362
+ forms of injected values. This limits accidental disclosure; local execution
363
+ has the calling user's filesystem and network access and is not a sandbox for
364
+ hostile code. Review the exact executable and grant only the credentials its
365
+ effects require. Cloud admission and cloud credential delivery remain separate.
366
+ SDK callers use `resolveSelectedRun`, `prepareSelectedSecretBindings` and
367
+ `executeSelectedLocal(selected, { secretBindings })` through `@hasna/skills/sdk`.
368
+
327
369
  ```bash
328
370
  skills capabilities --json
329
371
  skills run --target cloud --selection-profile default \
@@ -684,6 +726,118 @@ and version-skew contract: `docs/architecture/remote-client-pins-tags-sync.md`.
684
726
  For the reusable upstream contract, see
685
727
  `docs/architecture/reusable-skills-engine.md`.
686
728
 
729
+ ### Recurring consent SDK
730
+
731
+ The SDK exposes `previewRecurringConsent`, `getRecurringDraft`,
732
+ `activateRecurringConsent`, `listRecurringConsents`, `getRecurringConsent`,
733
+ `listRecurringOccurrences` and `revokeRecurringConsent`. These require a server
734
+ that explicitly advertises the version-1 recurring capability; an unavailable
735
+ server raises `RemoteRecurringUnavailableError`. This client does not create
736
+ local schedules or enable a server policy. Use `createRemoteSkillsClient` for the
737
+ existing selected-profile/API binding, or construct `RemoteSkillsClient` with an
738
+ explicit bearer and API URL. Each operation captures that connection and all
739
+ inputs before asynchronous work. An optional final `RemoteWorkspaceContext`
740
+ restricts it to an observed user and membership; profile files are unchanged.
741
+
742
+ `RecurringRequest` carries explicit cadence, lifetime, runtime limits and credit
743
+ and occurrence ceilings. A preview returns immutable terms, their hash, the
744
+ original quote and approval deadline; its quote states that admission reprices.
745
+ Draft retrieval retains those values even after expiry and never refreshes the
746
+ deadline. Activation requires the original draft ID and `RecurringActivation`:
747
+ `contractVersion: 1`, its exact `acceptedTermsSha256`, the literal acceptance
748
+ `authorize-recurring-credit-use`, and a caller-owned idempotency key. The client
749
+ reads the stored draft before submitting; the server independently requires
750
+ current fresh human authority. Client metadata cannot grant that authority.
751
+ Read operations require `schedules:read`, while preview and revocation require
752
+ `schedules:manage`; API keys cannot activate a grant. Consent read/history/revoke
753
+ preserve tenant-wide control, including retained grants from other deployments.
754
+
755
+ `RemoteRecurringUnconfirmedError` means a dispatched mutation could have
756
+ committed. Keep its original server/account, inputs, terms hash and request key;
757
+ explicitly reconcile that same identity with current authority. The client never
758
+ retries a POST, creates a replacement key or asserts rollback. After uncertain
759
+ revocation, inspect the original consent and occurrences; revocation does not
760
+ promise cancellation of an already authorized attempt. Exact domain not-found
761
+ responses return `null` only for draft/consent reads. Malformed or oversized
762
+ responses fail closed. Pages accept 1–100 items and an opaque cursor; a large
763
+ terms page can exceed the 64-MiB response bound, so request a smaller page
764
+ explicitly. JSON input is limited to 1 MiB and 64 nesting levels. Dashboard
765
+ approval and server enablement remain separate from these client interfaces.
766
+
767
+ ### Recurring consent from the terminal or MCP
768
+
769
+ `skills recurring` uses the same hosted SDK methods. Existing `skills schedule`
770
+ commands retain their local metadata and one-shot behavior. A compatible server
771
+ must already support recurring consent; these commands install no server policy,
772
+ daemon or default key scopes. Read/draft/history require `schedules:read`, and
773
+ preview/revocation require `schedules:manage`.
774
+
775
+ | Command | MCP tool |
776
+ | --- | --- |
777
+ | `recurring preview --request <file>` | `preview_recurring_consent` |
778
+ | `recurring draft <draft-id>` | `get_recurring_draft` |
779
+ | `recurring activate <draft-id>` | `activate_recurring_consent` |
780
+ | `recurring list` / `recurring get <consent-id>` | `list_recurring_consents` / `get_recurring_consent` |
781
+ | `recurring occurrences <consent-id>` | `list_recurring_occurrences` |
782
+ | `recurring revoke <consent-id> --confirm` | `revoke_recurring_consent` |
783
+ | `recurring recover --recovery-dir <original-directory>` | `recover_recurring_consent` |
784
+ | `recurring verification <draft-id> --email <email> --confirm` | `request_recurring_verification` |
785
+
786
+ Use the CLI's existing `--profile <name>` before the command, or the MCP host's
787
+ explicitly configured connection. Fresh approval needs an enrolled workspace
788
+ profile or both observed `--user-id` and `--membership-id`; those IDs restrict
789
+ current authority. The target, profile and credential are captured before prompts
790
+ and checked again before changes. No operation switches or overwrites saved
791
+ credentials. A normal API-key login alone cannot activate recurring spend.
792
+ Before requesting or verifying a code, the client checks the selected key's
793
+ current account email, trimming whitespace and ignoring case as the server does.
794
+ A different email is refused before the login endpoint can create an account.
795
+
796
+ The request file contains every explicit `RecurringRequest` field, including
797
+ JSON input/args, runtime and connector limits, cadence/start/expiry/grace, UTC-day
798
+ period, finish-authorized-attempt policy, all three credit ceilings and both
799
+ occurrence ceilings. No policy values are inferred. Preview and draft retrieval
800
+ show the original server terms/hash, quote, first due instants and approval
801
+ deadline. They create no run or credit reservation. Each grant adds its own
802
+ budget; an occurrence reprices within the approved limits.
803
+
804
+ To activate, provide `--accepted-terms <original-sha256>`,
805
+ `--idempotency-key <original-key>`, `--recovery-dir <new-absolute-directory>`,
806
+ `--email <email>` and `--confirm`. A terminal displays the complete immutable
807
+ draft and requires typing `authorize-recurring-credit-use`, then requests a
808
+ fresh code and reads it masked. For JSON or noninteractive use, also supply
809
+ `--acceptance authorize-recurring-credit-use --code-stdin`; request the code
810
+ first with `recurring verification`. Do not put the code or session in argv.
811
+ Cancellation/EOF does not grant consent. The server independently verifies fresh,
812
+ eligible, non-impersonated human authority and the original terms.
813
+
814
+ MCP activation takes the same original draft, approval object, recovery directory
815
+ and explicit `confirm: true`, plus account email and a fresh code. The MCP host
816
+ may retain supplied code arguments in its history; the masked terminal flow
817
+ avoids that disclosure. No tool returns or stores the resulting session. A tool
818
+ confirmation boolean or API key never substitutes for verified human approval.
819
+
820
+ Activation and revocation require a new recovery directory under an existing
821
+ canonical parent. It is created privately and contains the original server,
822
+ profile, account/membership, draft/hash/approval key or consent ID and attempt
823
+ state. It contains no bearer, OTP or raw input payload. Preserve it after errors;
824
+ unknown mutation outcomes exit 2 in the CLI and set MCP `isError` with
825
+ `outcomeUnknown: true`. Read-only `recover` never resubmits. Explicit
826
+ `recover --confirm` reuses the original activation key/terms and fresh approval,
827
+ or the same revoked consent; it never creates a replacement request. An expired
828
+ draft or lost current authority does not resolve an earlier unknown outcome.
829
+ Aliased, replaced, malformed or locked recovery directories refuse changes.
830
+
831
+ List/history expose one page (1–100 items, default 20) and the unchanged opaque
832
+ cursor. Consent output includes period/total reserved and settled credits,
833
+ admitted counts, ceilings, deployment and next due time; history includes stable
834
+ occurrence/run IDs, outcomes, refusal reasons and allocation state. All hosts
835
+ read the same server identities. Revocation reports residual authorized exposure
836
+ and does not promise cancellation/refund of an already authorized attempt.
837
+ Cancellation is separate. A lost preview response has no draft lookup key:
838
+ report that uncertainty and explicitly choose any new preview, without silently
839
+ turning it into an activation.
840
+
687
841
  ## Portable Skills
688
842
 
689
843
  Portable skills live under `~/.hasna/skills/installed/<name>/` and follow the
@@ -1055,7 +1209,7 @@ src/
1055
1209
  |---|---|---|
1056
1210
  | Catalog skills | 0 | `SKILLS.length` (`src/lib/registry-data/`) |
1057
1211
  | Categories | 17 | `CATEGORIES` (`src/lib/registry-types.ts`) |
1058
- | MCP tools | 72 | `tools/list` against a live `buildServer()` |
1212
+ | MCP tools | 81 | `tools/list` against a live `buildServer()` |
1059
1213
 
1060
1214
  Every number in this table is re-derived from the source tree on each test run by
1061
1215
  `src/lib/readme-derived-counts.test.ts`, so a drifted figure fails a test rather