stateplane 0.0.1 → 0.1.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.
- package/README.md +15 -4
- package/bin/stateplane.js +2 -1
- package/package.json +11 -11
- package/bin/keychain.swift +0 -19
- package/bin/secure-acl.ps1 +0 -69
- package/dist/config.d.ts +0 -41
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1329
- package/dist/run.d.ts +0 -3
- package/dist/transport.d.ts +0 -54
package/README.md
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
# stateplane
|
|
2
2
|
|
|
3
|
-
Stateplane is 21n's shared state service for all your agents: a generic owned-state service with a versioned v1
|
|
3
|
+
Stateplane is 21n's shared state service for all your agents: a generic owned-state service with a versioned v1
|
|
4
|
+
logical contract, a transactional Postgres authority, owned-space identity and regional policy, an HTTP/CLI v1
|
|
5
|
+
transport, remote MCP, an owner UI and a durable outbox. It is under active construction; the service runs from the
|
|
6
|
+
[21nCo/stateplane](https://github.com/21nCo/stateplane) repository.
|
|
4
7
|
|
|
5
|
-
This package
|
|
8
|
+
This package is Stateplane's front door on npm: its `stateplane` command runs the Stateplane command line,
|
|
9
|
+
[`@stateplane/cli`](https://www.npmjs.com/package/@stateplane/cli), which it pins to its own version.
|
|
6
10
|
|
|
7
11
|
```sh
|
|
8
|
-
npx stateplane
|
|
12
|
+
npx stateplane help
|
|
13
|
+
npx stateplane config endpoint --url https://stateplane.example.invalid/
|
|
9
14
|
```
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
`stateplane` and `@stateplane/cli` are released together, always at one version. The package has no library export;
|
|
17
|
+
scripts that call the CLI's client import `@stateplane/cli`. Requires Node.js 22.13 or newer. Docs:
|
|
18
|
+
[HTTP and CLI v1](https://github.com/21nCo/stateplane/blob/main/docs/http-cli.md).
|
|
19
|
+
|
|
20
|
+
## Versions
|
|
21
|
+
|
|
22
|
+
0.1.1 is the first release on npm: the release build of 0.1.0 failed in CI and was never published.
|
package/bin/stateplane.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
// `npx stateplane`: the Stateplane command line, @stateplane/cli, which this package pins to its own version.
|
|
2
3
|
import process from 'node:process';
|
|
3
|
-
import { runCli } from '
|
|
4
|
+
import { runCli } from '@stateplane/cli';
|
|
4
5
|
process.exitCode = await runCli(process.argv.slice(2));
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stateplane",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Stateplane
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Stateplane: shared state for all your agents. `npx stateplane` runs the Stateplane command line, @stateplane/cli.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author": "21n",
|
|
7
6
|
"type": "module",
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
10
7
|
"bin": {
|
|
11
|
-
"stateplane": "bin/stateplane.js"
|
|
8
|
+
"stateplane": "./bin/stateplane.js"
|
|
12
9
|
},
|
|
13
10
|
"files": [
|
|
14
11
|
"bin",
|
|
15
|
-
"dist",
|
|
16
12
|
"README.md"
|
|
17
13
|
],
|
|
18
14
|
"engines": {
|
|
19
|
-
"node": ">=22.
|
|
15
|
+
"node": ">=22.13.0"
|
|
20
16
|
},
|
|
21
17
|
"repository": {
|
|
22
18
|
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/21nCo/stateplane.git"
|
|
19
|
+
"url": "git+https://github.com/21nCo/stateplane.git",
|
|
20
|
+
"directory": "packages/stateplane"
|
|
24
21
|
},
|
|
25
|
-
"homepage": "https://github.com/21nCo/stateplane#readme"
|
|
26
|
-
|
|
22
|
+
"homepage": "https://github.com/21nCo/stateplane#readme",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@stateplane/cli": "0.1.1"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/bin/keychain.swift
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import Security
|
|
3
|
-
|
|
4
|
-
// Tokens cross this process boundary only on stdin/stdout, never in argv.
|
|
5
|
-
guard CommandLine.arguments.count == 3 else { exit(1) }
|
|
6
|
-
let operation = CommandLine.arguments[1]
|
|
7
|
-
let service = CommandLine.arguments[2]
|
|
8
|
-
let query: [String: Any] = [
|
|
9
|
-
kSecClass as String: kSecClassGenericPassword,
|
|
10
|
-
kSecAttrAccount as String: "default",
|
|
11
|
-
kSecAttrService as String: service
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
// This helper only deletes legacy items. A Swift interpreter has no caller
|
|
15
|
-
// identity that can safely restrict credential reads to Stateplane.
|
|
16
|
-
if operation == "remove" {
|
|
17
|
-
let status = SecItemDelete(query as CFDictionary)
|
|
18
|
-
guard status == errSecSuccess || status == errSecItemNotFound else { exit(1) }
|
|
19
|
-
} else { exit(1) }
|
package/bin/secure-acl.ps1
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[Parameter(Mandatory=$true)][string]$TargetPath,
|
|
3
|
-
[ValidateSet('harden','verify','diagnose')][string]$Action='verify'
|
|
4
|
-
)
|
|
5
|
-
$ErrorActionPreference='Stop'
|
|
6
|
-
$identity=[System.Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
7
|
-
$allowed=@($identity.Value,'S-1-5-18','S-1-5-32-544')
|
|
8
|
-
function ReadAcl($path) {
|
|
9
|
-
# FileInfo/DirectoryInfo use the framework ACL API directly. The packaged
|
|
10
|
-
# CLI must not depend on PowerShell module autoload in a fresh user profile.
|
|
11
|
-
if ([System.IO.Directory]::Exists($path)) {
|
|
12
|
-
return ([System.IO.DirectoryInfo]::new($path)).GetAccessControl()
|
|
13
|
-
}
|
|
14
|
-
if ([System.IO.File]::Exists($path)) {
|
|
15
|
-
return ([System.IO.FileInfo]::new($path)).GetAccessControl()
|
|
16
|
-
}
|
|
17
|
-
exit 14
|
|
18
|
-
}
|
|
19
|
-
$acl=ReadAcl $TargetPath
|
|
20
|
-
function RulesBySid($security) {
|
|
21
|
-
# Get-Acl.Access can hold NTAccount names that no longer translate on a
|
|
22
|
-
# runner. Asking the ACL for SIDs also makes the allowlist comparison exact.
|
|
23
|
-
return @($security.GetAccessRules($true,$false,[System.Security.Principal.SecurityIdentifier]))
|
|
24
|
-
}
|
|
25
|
-
if ($Action -eq 'diagnose') {
|
|
26
|
-
$owner=$acl.GetOwner([System.Security.Principal.SecurityIdentifier]).Value
|
|
27
|
-
$rules=@(RulesBySid $acl | ForEach-Object {
|
|
28
|
-
$sid=$_.IdentityReference.Value
|
|
29
|
-
"$sid/$($_.AccessControlType)/$($_.IsInherited)"
|
|
30
|
-
}) -join ','
|
|
31
|
-
Write-Output "pid=$PID caller=$($identity.Value) owner=$owner protected=$($acl.AreAccessRulesProtected) rules=$rules"
|
|
32
|
-
exit 0
|
|
33
|
-
}
|
|
34
|
-
if ($Action -eq 'harden') {
|
|
35
|
-
# Set-Acl writes the owner as well as the DACL. A Windows runner may create
|
|
36
|
-
# a file owned by Administrators while the CLI runs as its member, in which
|
|
37
|
-
# case that owner write fails despite the caller being allowed to edit DACLs.
|
|
38
|
-
$icacls=Join-Path $env:SystemRoot 'System32\icacls.exe'
|
|
39
|
-
if (-not [System.IO.File]::Exists($icacls)) { exit 10 }
|
|
40
|
-
$suffix=if ([System.IO.Directory]::Exists($TargetPath)) { ':(OI)(CI)F' } else { ':F' }
|
|
41
|
-
# Grant our own SID before removing inherited rules. The system accounts
|
|
42
|
-
# retain access for backup and machine administration.
|
|
43
|
-
foreach ($sid in $allowed) {
|
|
44
|
-
& $icacls $TargetPath '/grant:r' "*$sid$suffix" | Out-Null
|
|
45
|
-
if ($LASTEXITCODE -ne 0) { exit 11 }
|
|
46
|
-
}
|
|
47
|
-
& $icacls $TargetPath '/inheritance:r' | Out-Null
|
|
48
|
-
if ($LASTEXITCODE -ne 0) { exit 12 }
|
|
49
|
-
$acl=ReadAcl $TargetPath
|
|
50
|
-
foreach ($rule in @(RulesBySid $acl)) {
|
|
51
|
-
$sid=$rule.IdentityReference.Value
|
|
52
|
-
if ($allowed -contains $sid) { continue }
|
|
53
|
-
& $icacls $TargetPath '/remove' "*$sid" | Out-Null
|
|
54
|
-
if ($LASTEXITCODE -ne 0) { exit 13 }
|
|
55
|
-
}
|
|
56
|
-
$acl=ReadAcl $TargetPath
|
|
57
|
-
}
|
|
58
|
-
if (-not $acl.AreAccessRulesProtected) { exit 1 }
|
|
59
|
-
$owner=$null
|
|
60
|
-
try { $owner=$acl.GetOwner([System.Security.Principal.SecurityIdentifier]).Value }
|
|
61
|
-
catch { exit 2 }
|
|
62
|
-
if ($allowed -notcontains $owner) { exit 2 }
|
|
63
|
-
$hasUser=$false
|
|
64
|
-
foreach ($rule in @(RulesBySid $acl)) {
|
|
65
|
-
$sid=$rule.IdentityReference.Value
|
|
66
|
-
if ($allowed -notcontains $sid -or $rule.AccessControlType -ne 'Allow') { exit 1 }
|
|
67
|
-
if ($sid -eq $identity.Value) { $hasUser=$true }
|
|
68
|
-
}
|
|
69
|
-
if (-not $hasUser) { exit 1 }
|
package/dist/config.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
type TokenStore = 'keychain' | 'file';
|
|
2
|
-
export interface CliConfig {
|
|
3
|
-
endpoint?: string;
|
|
4
|
-
space?: string;
|
|
5
|
-
tokenStore?: TokenStore;
|
|
6
|
-
tokenLocations?: TokenStore[];
|
|
7
|
-
}
|
|
8
|
-
export declare function configDir(): string;
|
|
9
|
-
export declare function withConfigMutation<T>(change: (current: CliConfig) => Promise<T>): Promise<T>;
|
|
10
|
-
export declare function readConfig(): Promise<CliConfig>;
|
|
11
|
-
export declare function saveConfig(value: CliConfig): Promise<void>;
|
|
12
|
-
interface CommandResult {
|
|
13
|
-
ok: boolean;
|
|
14
|
-
output: string;
|
|
15
|
-
missing?: boolean;
|
|
16
|
-
}
|
|
17
|
-
declare function command(program: string, args: string[], stdin?: string): Promise<CommandResult>;
|
|
18
|
-
export declare function loadSecretServiceToken(endpoint: string, run?: typeof command): Promise<string>;
|
|
19
|
-
export declare function loadOsSecretToken(endpoint: string, os?: NodeJS.Platform, run?: typeof command): Promise<string>;
|
|
20
|
-
export declare function storeSecretServiceToken(endpoint: string, token: string, run?: typeof command): Promise<void>;
|
|
21
|
-
/** secret-tool clear exits 1 when there was no item to remove. Confirm that
|
|
22
|
-
* absence with a lookup before treating it as successful cleanup. */
|
|
23
|
-
export declare function removeSecretServiceToken(endpoint: string, run?: typeof command): Promise<void>;
|
|
24
|
-
export declare function saveToken(endpoint: string, token: string, store: 'keychain' | 'file'): Promise<void>;
|
|
25
|
-
export declare function loadToken(config: CliConfig): Promise<string>;
|
|
26
|
-
export declare function removeToken(config: CliConfig): Promise<void>;
|
|
27
|
-
type TokenPersistence = {
|
|
28
|
-
saveConfig: typeof saveConfig;
|
|
29
|
-
saveToken: typeof saveToken;
|
|
30
|
-
removeToken: typeof removeToken;
|
|
31
|
-
};
|
|
32
|
-
/** Keep both possible locations discoverable until the old secret is gone.
|
|
33
|
-
* Each persisted step can be retried or cleaned up after process interruption. */
|
|
34
|
-
export declare function configureToken(config: CliConfig, token: string, store: 'keychain' | 'file', io?: TokenPersistence): Promise<void>;
|
|
35
|
-
/** Logout and endpoint changes also clean a transition interrupted at any step. */
|
|
36
|
-
export declare function removeTrackedTokens(config: CliConfig, io?: Pick<TokenPersistence, 'removeToken'>): Promise<void>;
|
|
37
|
-
export declare function logoutConfig(config: CliConfig, io?: {
|
|
38
|
-
removeTrackedTokens: typeof removeTrackedTokens;
|
|
39
|
-
saveConfig: typeof saveConfig;
|
|
40
|
-
}): Promise<void>;
|
|
41
|
-
export {};
|
package/dist/index.d.ts
DELETED