@inneranimalmedia/agentsam-sdk 2.6.1 → 2.6.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/docs/AUTH_IDENTITY_CONTRACT.md +25 -27
- package/docs/SDK_WORKER.md +4 -3
- package/package.json +1 -1
- package/packages/identity/package.json +2 -2
- package/packages/identity/src/contracts/auth-config.js +23 -40
- package/packages/identity/tests/auth-config.test.mjs +14 -23
- package/src/cli.js +13 -23
- package/src/commands/account-auth.js +1 -1
- package/src/commands/deploy.js +2 -2
- package/src/commands/providers.js +308 -0
- package/src/commands/shell.js +4 -0
- package/src/commands/tunnel.js +8 -8
- package/src/commands/whoami.js +42 -21
- package/src/errors/diagnostic.js +1 -0
- package/src/lib/account-session.js +94 -25
- package/src/lib/auth.js +314 -51
- package/src/lib/core-client.js +75 -30
- package/src/lib/detect-context.js +14 -16
- package/src/lib/provider-credentials.js +171 -55
- package/src/lib/slash-commands.js +1 -0
- package/src/models/discovery.js +35 -0
- package/src/ui/cli/help.js +3 -1
- package/test/account-session.test.mjs +48 -11
- package/test/apps-scaffold-contract.test.mjs +43 -0
- package/test/sdk-worker-contract.test.mjs +5 -1
- package/test/smoke.mjs +2 -1
- package/test/whoami-resume.test.mjs +6 -5
- package/src/lib/prompt-byok.js +0 -57
- package/src/lib/save-sdk-token.js +0 -19
|
@@ -6,47 +6,45 @@ The `agentsam-sdk` package owns the portable public configuration contract. Cons
|
|
|
6
6
|
|
|
7
7
|
| Variable | Meaning |
|
|
8
8
|
| --- | --- |
|
|
9
|
-
| `
|
|
9
|
+
| `IAM_OAUTH_ISSUER` | Canonical IAM authority/issuer for browser OAuth and platform account requests. |
|
|
10
|
+
| `IAM_ORIGIN` | Migration fallback for the IAM issuer. New code resolves `IAM_OAUTH_ISSUER` first. |
|
|
10
11
|
| `IAM_CLIENT_ID` | OAuth client id for an application using IAM identity. |
|
|
11
12
|
| `IAM_CLIENT_SECRET` | OAuth client secret. Keep it server-side. |
|
|
12
|
-
| `
|
|
13
|
-
| `AGENTSAM_BRIDGE_KEY` |
|
|
13
|
+
| `AGENTSAM_API_KEY` | Reusable account/delegated API credential. Raw values use the `aak_` prefix and are sent as `Authorization: Bearer …`. |
|
|
14
|
+
| `AGENTSAM_BRIDGE_KEY` | Infrastructure/machine integration trust. It is never a substitute for account authentication. |
|
|
14
15
|
|
|
15
|
-
The host-side durable verifier for
|
|
16
|
+
The host-side durable verifier for reusable AgentSam API credentials is `agentsam_api_credentials`. The SDK defines the public credential semantics; the host owns credential issuance, hashing, storage, revocation, and authorization.
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
Interactive browser login is intentionally separate from `AGENTSAM_API_KEY`. The CLI stores an opaque machine-local browser session under `~/.agentsam/auth/session.json`; it does not turn that session into a reusable API key.
|
|
18
19
|
|
|
19
20
|
## Migration compatibility
|
|
20
21
|
|
|
21
|
-
The
|
|
22
|
+
The issuer resolver accepts `IAM_ORIGIN` only when `IAM_OAUTH_ISSUER` is absent. The retired `AGENTSAM_SDK_KEY`, `AGENTSAM_SDK_TOKEN`, `sdk_` bearer, and `agentsam_sdk_tokens` account-auth contract is not read by the current SDK.
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
IAM_ORIGIN
|
|
25
|
-
fallback: IAM_OAUTH_ISSUER
|
|
26
|
-
|
|
27
|
-
AGENTSAM_SDK_KEY
|
|
28
|
-
fallback: AGENTSAM_SDK_TOKEN
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Canonical names always win when both are present. New scaffolds, docs, and writes emit only the canonical names. Compatibility aliases are intentionally not a permanent parallel configuration surface.
|
|
32
|
-
|
|
33
|
-
Older platform-base aliases (`IAM_CORE_URL`, `AGENTSAM_CORE_URL`, `AGENTSAM_BASE_URL`) are compatibility-only. SDK clients prefer `IAM_ORIGIN`.
|
|
24
|
+
Older platform-base aliases (`IAM_CORE_URL`, `AGENTSAM_CORE_URL`, `AGENTSAM_BASE_URL`) remain compatibility-only where legacy clients still consume them.
|
|
34
25
|
|
|
35
26
|
## Credential boundaries
|
|
36
27
|
|
|
37
28
|
```text
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
->
|
|
41
|
-
-> Authorization: Bearer <
|
|
29
|
+
reusable account API lane
|
|
30
|
+
AGENTSAM_API_KEY
|
|
31
|
+
-> aak_* bearer
|
|
32
|
+
-> Authorization: Bearer <aak_*>
|
|
42
33
|
-> account/delegated authority
|
|
43
|
-
->
|
|
34
|
+
-> agentsam_api_credentials (hashed verifier on the host)
|
|
35
|
+
|
|
36
|
+
interactive browser lane
|
|
37
|
+
agentsam login
|
|
38
|
+
-> opaque browser session credential
|
|
39
|
+
-> ~/.agentsam/auth/session.json
|
|
40
|
+
-> interactive account authority
|
|
41
|
+
-> never rewritten as AGENTSAM_API_KEY
|
|
44
42
|
|
|
45
|
-
machine/
|
|
46
|
-
|
|
43
|
+
machine/infrastructure lane
|
|
44
|
+
enrolled opaque machine credential / infrastructure bridge trust
|
|
47
45
|
-> machine principal
|
|
48
|
-
->
|
|
49
|
-
->
|
|
46
|
+
-> server resolves connection -> instance -> account
|
|
47
|
+
-> never accepted as account API auth
|
|
50
48
|
```
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
Repository identity, workspace labels, terminal instance ids, and machine trust do not prove reusable account authority. Provider credentials such as `OPENAI_API_KEY`, `GEMINI_API_KEY`, `CURSOR_API_KEY`, and Cloudflare credentials are managed separately by the machine provider-credential service.
|
package/docs/SDK_WORKER.md
CHANGED
|
@@ -47,16 +47,17 @@ agentsam-sdk
|
|
|
47
47
|
├─ AGENTSAM_WAI -> Workers AI provider
|
|
48
48
|
├─ EXECOS -> execos service binding
|
|
49
49
|
├─ PTY_SERVICE -> iam-vpc VPC service
|
|
50
|
-
├─
|
|
50
|
+
├─ IAM_OAUTH_ISSUER -> https://inneranimalmedia.com
|
|
51
|
+
├─ IAM_ORIGIN -> migration fallback
|
|
51
52
|
├─ IAM_CLIENT_ID -> public OAuth client id
|
|
52
53
|
├─ IAM_CLIENT_SECRET -> secret
|
|
53
|
-
├─
|
|
54
|
+
├─ AGENTSAM_API_KEY -> aak_ account credential (only when a reusable account credential is needed)
|
|
54
55
|
└─ AGENTSAM_BRIDGE_KEY -> secret
|
|
55
56
|
```
|
|
56
57
|
|
|
57
58
|
Hosted model credentials are secrets: `XAI_API_KEY`, `OPENAI_API_KEY`, and `GEMINI_API_KEY`. Grok model inference is the `XAI_API_KEY` provider lane and is independent from the pre-wired Grok gate viewer identity/session system.
|
|
58
59
|
|
|
59
|
-
`AGENTSAM_WORKER_ROLE` is not part of the SDK contract. `IAM_OAUTH_ISSUER`
|
|
60
|
+
`AGENTSAM_WORKER_ROLE` is not part of the SDK contract. `IAM_OAUTH_ISSUER` is the canonical IAM authority; `IAM_ORIGIN` is a migration fallback. Reusable account API credentials use `AGENTSAM_API_KEY` with an `aak_` prefix. Browser login sessions and machine/infrastructure credentials remain separate and must not be promoted into account API keys.
|
|
60
61
|
|
|
61
62
|
## Ollama
|
|
62
63
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inneranimalmedia/agentsam-sdk",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "Portable AgentSam SDK and CLI kits for local scaffolding, repository intelligence, incremental indexing, identity adapters, and verified dependency maintenance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inneranimalmedia/agentsam-sdk-identity",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Identity module for @inneranimalmedia/agentsam-sdk (workspace
|
|
6
|
+
"description": "Identity module for @inneranimalmedia/agentsam-sdk (workspace \u2014 publish via root SDK)",
|
|
7
7
|
"agentsam": {
|
|
8
8
|
"system": "identity",
|
|
9
9
|
"kind": "library",
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canonical AgentSam identity/auth environment contract.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Canonical variables:
|
|
8
|
-
* IAM_OAUTH_ISSUER public authorization-server authority (issuer)
|
|
9
|
-
* IAM_CLIENT_ID OAuth client id
|
|
10
|
-
* IAM_CLIENT_SECRET OAuth client secret
|
|
11
|
-
* IAM_ORIGIN deprecated alias of IAM_OAUTH_ISSUER (migration window)
|
|
12
|
-
* AGENTSAM_SDK_KEY account/delegated sdk_* bearer
|
|
13
|
-
* AGENTSAM_BRIDGE_KEY machine/integration credential
|
|
14
|
-
*
|
|
15
|
-
* Migration-only fallbacks:
|
|
16
|
-
* IAM_ORIGIN -> IAM_OAUTH_ISSUER
|
|
17
|
-
* AGENTSAM_SDK_TOKEN -> AGENTSAM_SDK_KEY
|
|
4
|
+
* Browser login sessions and reusable API credentials are intentionally
|
|
5
|
+
* separate: login sessions are opaque, machine-local session state while
|
|
6
|
+
* AGENTSAM_API_KEY is an explicit delegated account credential.
|
|
18
7
|
*/
|
|
19
8
|
|
|
20
9
|
export const DEFAULT_IAM_OAUTH_ISSUER = 'https://inneranimalmedia.com';
|
|
@@ -26,17 +15,12 @@ export const AGENTSAM_AUTH_ENV = Object.freeze({
|
|
|
26
15
|
iamOrigin: 'IAM_ORIGIN',
|
|
27
16
|
iamClientId: 'IAM_CLIENT_ID',
|
|
28
17
|
iamClientSecret: 'IAM_CLIENT_SECRET',
|
|
29
|
-
|
|
18
|
+
apiKey: 'AGENTSAM_API_KEY',
|
|
30
19
|
bridgeKey: 'AGENTSAM_BRIDGE_KEY',
|
|
31
20
|
});
|
|
32
21
|
|
|
33
|
-
export const AGENTSAM_AUTH_LEGACY_ENV = Object.freeze({
|
|
34
|
-
iamOrigin: 'IAM_ORIGIN',
|
|
35
|
-
sdkKey: 'AGENTSAM_SDK_TOKEN',
|
|
36
|
-
});
|
|
37
|
-
|
|
38
22
|
export const AGENTSAM_AUTH_CONTRACT = Object.freeze({
|
|
39
|
-
version:
|
|
23
|
+
version: 2,
|
|
40
24
|
authority: 'agentsam-sdk',
|
|
41
25
|
iam: Object.freeze({
|
|
42
26
|
issuer: AGENTSAM_AUTH_ENV.iamIssuer,
|
|
@@ -44,24 +28,23 @@ export const AGENTSAM_AUTH_CONTRACT = Object.freeze({
|
|
|
44
28
|
clientId: AGENTSAM_AUTH_ENV.iamClientId,
|
|
45
29
|
clientSecret: AGENTSAM_AUTH_ENV.iamClientSecret,
|
|
46
30
|
}),
|
|
47
|
-
|
|
48
|
-
env: AGENTSAM_AUTH_ENV.
|
|
49
|
-
tokenPrefix: '
|
|
31
|
+
apiKey: Object.freeze({
|
|
32
|
+
env: AGENTSAM_AUTH_ENV.apiKey,
|
|
33
|
+
tokenPrefix: 'aak_',
|
|
50
34
|
authorizationScheme: 'Bearer',
|
|
51
35
|
subject: 'account/delegated',
|
|
52
|
-
durableStore: '
|
|
36
|
+
durableStore: 'agentsam_api_credentials',
|
|
37
|
+
}),
|
|
38
|
+
browserSession: Object.freeze({
|
|
39
|
+
storage: '~/.agentsam/auth/session.json',
|
|
40
|
+
subject: 'interactive/user',
|
|
41
|
+
reusableApiCredential: false,
|
|
53
42
|
}),
|
|
54
43
|
bridge: Object.freeze({
|
|
55
44
|
env: AGENTSAM_AUTH_ENV.bridgeKey,
|
|
56
45
|
subject: 'machine/integration',
|
|
57
|
-
sdkTokenType: 'integration',
|
|
58
46
|
userAuth: false,
|
|
59
47
|
}),
|
|
60
|
-
compatibility: Object.freeze({
|
|
61
|
-
iamOriginFallback: AGENTSAM_AUTH_LEGACY_ENV.iamOrigin,
|
|
62
|
-
iamIssuerCanonical: AGENTSAM_AUTH_ENV.iamIssuer,
|
|
63
|
-
sdkKeyFallback: AGENTSAM_AUTH_LEGACY_ENV.sdkKey,
|
|
64
|
-
}),
|
|
65
48
|
});
|
|
66
49
|
|
|
67
50
|
function clean(value) {
|
|
@@ -84,24 +67,24 @@ export function resolveIamOrigin(env = {}, explicit = '') {
|
|
|
84
67
|
return resolveIamIssuer(env, explicit);
|
|
85
68
|
}
|
|
86
69
|
|
|
87
|
-
/** Resolve
|
|
88
|
-
export function
|
|
89
|
-
return clean(explicit || env?.
|
|
70
|
+
/** Resolve the reusable delegated account API credential. */
|
|
71
|
+
export function resolveApiKey(env = {}, explicit = '') {
|
|
72
|
+
return clean(explicit || env?.AGENTSAM_API_KEY);
|
|
90
73
|
}
|
|
91
74
|
|
|
92
|
-
/** Resolve machine/integration bridge credential. No
|
|
75
|
+
/** Resolve machine/integration bridge credential. No account API-key alias is accepted. */
|
|
93
76
|
export function resolveBridgeKey(env = {}, explicit = '') {
|
|
94
77
|
return clean(explicit || env?.AGENTSAM_BRIDGE_KEY);
|
|
95
78
|
}
|
|
96
79
|
|
|
97
|
-
export function
|
|
98
|
-
return clean(value).startsWith(AGENTSAM_AUTH_CONTRACT.
|
|
80
|
+
export function isApiKey(value) {
|
|
81
|
+
return clean(value).startsWith(AGENTSAM_AUTH_CONTRACT.apiKey.tokenPrefix);
|
|
99
82
|
}
|
|
100
83
|
|
|
101
|
-
/** Build the public bearer header for an
|
|
102
|
-
export function
|
|
84
|
+
/** Build the public bearer header for an AgentSam account API key. */
|
|
85
|
+
export function buildApiAuthorizationHeaders(key, headers = {}) {
|
|
103
86
|
const resolved = clean(key);
|
|
104
|
-
if (!
|
|
87
|
+
if (!isApiKey(resolved)) throw new Error('AGENTSAM_API_KEY_required');
|
|
105
88
|
return {
|
|
106
89
|
...headers,
|
|
107
90
|
Authorization: `Bearer ${resolved}`,
|
|
@@ -2,10 +2,10 @@ import assert from 'node:assert/strict';
|
|
|
2
2
|
import { describe, it } from 'node:test';
|
|
3
3
|
import {
|
|
4
4
|
AGENTSAM_AUTH_CONTRACT,
|
|
5
|
-
|
|
5
|
+
buildApiAuthorizationHeaders,
|
|
6
|
+
resolveApiKey,
|
|
6
7
|
resolveBridgeKey,
|
|
7
8
|
resolveIamOrigin,
|
|
8
|
-
resolveSdkKey,
|
|
9
9
|
} from '../src/contracts/auth-config.js';
|
|
10
10
|
|
|
11
11
|
describe('auth configuration contract', () => {
|
|
@@ -20,42 +20,33 @@ describe('auth configuration contract', () => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('accepts IAM_ORIGIN as migration-only fallback', () => {
|
|
23
|
-
assert.equal(
|
|
24
|
-
resolveIamOrigin({ IAM_ORIGIN: 'https://legacy.example.test/' }),
|
|
25
|
-
'https://legacy.example.test',
|
|
26
|
-
);
|
|
23
|
+
assert.equal(resolveIamOrigin({ IAM_ORIGIN: 'https://legacy.example.test/' }), 'https://legacy.example.test');
|
|
27
24
|
});
|
|
28
25
|
|
|
29
26
|
it('defaults issuer when neither IAM_OAUTH_ISSUER nor IAM_ORIGIN exists', () => {
|
|
30
27
|
assert.equal(resolveIamOrigin({}), 'https://inneranimalmedia.com');
|
|
31
28
|
});
|
|
32
29
|
|
|
33
|
-
it('
|
|
34
|
-
assert.equal(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
AGENTSAM_SDK_TOKEN: 'sdk_old',
|
|
38
|
-
}),
|
|
39
|
-
'sdk_new',
|
|
40
|
-
);
|
|
41
|
-
assert.equal(resolveSdkKey({ AGENTSAM_SDK_TOKEN: 'sdk_old' }), 'sdk_old');
|
|
30
|
+
it('resolves only AGENTSAM_API_KEY for delegated account API auth', () => {
|
|
31
|
+
assert.equal(resolveApiKey({ AGENTSAM_API_KEY: 'aak_new' }), 'aak_new');
|
|
32
|
+
assert.equal(resolveApiKey({ AGENTSAM_SDK_KEY: 'sdk_old' }), '');
|
|
33
|
+
assert.equal(AGENTSAM_AUTH_CONTRACT.apiKey.durableStore, 'agentsam_api_credentials');
|
|
42
34
|
});
|
|
43
35
|
|
|
44
|
-
it('never aliases bridge machine trust to
|
|
36
|
+
it('never aliases bridge machine trust to an account API key', () => {
|
|
45
37
|
assert.equal(
|
|
46
|
-
resolveBridgeKey({ AGENTSAM_BRIDGE_KEY: 'bridge_machine',
|
|
38
|
+
resolveBridgeKey({ AGENTSAM_BRIDGE_KEY: 'bridge_machine', AGENTSAM_API_KEY: 'aak_user' }),
|
|
47
39
|
'bridge_machine',
|
|
48
40
|
);
|
|
49
|
-
assert.equal(resolveBridgeKey({
|
|
41
|
+
assert.equal(resolveBridgeKey({ AGENTSAM_API_KEY: 'aak_user' }), '');
|
|
50
42
|
assert.equal(AGENTSAM_AUTH_CONTRACT.bridge.userAuth, false);
|
|
51
|
-
assert.equal(AGENTSAM_AUTH_CONTRACT.bridge.sdkTokenType, 'integration');
|
|
52
43
|
});
|
|
53
44
|
|
|
54
|
-
it('builds Bearer authorization only for
|
|
55
|
-
assert.deepEqual(
|
|
45
|
+
it('builds Bearer authorization only for aak_ API keys', () => {
|
|
46
|
+
assert.deepEqual(buildApiAuthorizationHeaders('aak_abc', { Accept: 'application/json' }), {
|
|
56
47
|
Accept: 'application/json',
|
|
57
|
-
Authorization: 'Bearer
|
|
48
|
+
Authorization: 'Bearer aak_abc',
|
|
58
49
|
});
|
|
59
|
-
assert.throws(() =>
|
|
50
|
+
assert.throws(() => buildApiAuthorizationHeaders('bridge_machine'), /AGENTSAM_API_KEY_required/);
|
|
60
51
|
});
|
|
61
52
|
});
|
package/src/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import pkg from '../package.json' with { type: 'json' };
|
|
4
|
-
import readline from 'readline';
|
|
5
4
|
import { cancel, intro, isCancel, outro, select, text } from '@clack/prompts';
|
|
6
5
|
import path from 'node:path';
|
|
7
6
|
import { buildLocalScaffoldMeta } from './lib/local-scaffold.js';
|
|
@@ -9,10 +8,10 @@ import { writeScaffoldFiles } from './lib/write-files.js';
|
|
|
9
8
|
import { initializeGitRepository } from './lib/init-git.js';
|
|
10
9
|
import { initializeLocalSqlite } from './local/sqlite.js';
|
|
11
10
|
import { printContextSummary } from './lib/detect-context.js';
|
|
12
|
-
import { promptOptionalByokKeys } from './lib/prompt-byok.js';
|
|
13
11
|
import { runStartLocal } from './commands/start-local.js';
|
|
14
12
|
import { runOllama } from './commands/ollama.js';
|
|
15
13
|
import { runModels } from './commands/models.js';
|
|
14
|
+
import { runProviders } from './commands/providers.js';
|
|
16
15
|
import { runEnv } from './commands/env.js';
|
|
17
16
|
import { runTunnel } from './commands/tunnel.js';
|
|
18
17
|
import { runDeploy } from './commands/deploy.js';
|
|
@@ -41,7 +40,7 @@ import { applyPresetSelection, runAdd, runCapabilities, runDev, runInspect } fro
|
|
|
41
40
|
import { listPresets, resolvePreset } from './presets/index.js';
|
|
42
41
|
import fs from 'node:fs';
|
|
43
42
|
import { repositoryRoot } from './knowledge/config.js';
|
|
44
|
-
import {
|
|
43
|
+
import { resolveAccountAuth } from './lib/account-session.js';
|
|
45
44
|
import { renderDiagnosticError } from './errors/index.js';
|
|
46
45
|
import { renderHelpOverview, runHelp } from './ui/cli/help.js';
|
|
47
46
|
|
|
@@ -53,13 +52,6 @@ function reportCliError(error) {
|
|
|
53
52
|
console.error(`\n${rendered}\n`);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
function createPrompt() {
|
|
57
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
58
|
-
return {
|
|
59
|
-
ask: (q) => new Promise((resolve) => rl.question(q, resolve)),
|
|
60
|
-
close: () => rl.close(),
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
55
|
|
|
64
56
|
function printHelp() {
|
|
65
57
|
console.log(renderHelpOverview(VERSION));
|
|
@@ -96,6 +88,7 @@ function printLegacyHelp() {
|
|
|
96
88
|
agentsam status [--json] Live local Git + DB + API + PTY status
|
|
97
89
|
agentsam db init|status Manage the project-local SQLite database
|
|
98
90
|
agentsam models Verify configured providers and selectable hosted/local models
|
|
91
|
+
agentsam providers Configure, verify, and remove machine provider credentials
|
|
99
92
|
agentsam env init <name> Create a secure provider profile + reusable shell loader
|
|
100
93
|
agentsam login Sign in to Inner Animal Media and persist a secure machine-local session
|
|
101
94
|
agentsam logout Sign out locally; provider credentials stay untouched
|
|
@@ -142,7 +135,7 @@ function printLegacyHelp() {
|
|
|
142
135
|
--quick Quick tunnel (default) — trycloudflare.com URL
|
|
143
136
|
--named Named CF tunnel (needs --tunnel-name --hostname --zone-id)
|
|
144
137
|
--port <n> Local PTY port (default 3099)
|
|
145
|
-
--token <
|
|
138
|
+
--token <aak_…> Use AGENTSAM_API_KEY-compatible account credential
|
|
146
139
|
|
|
147
140
|
Init options:
|
|
148
141
|
--name <name> Project directory name
|
|
@@ -235,11 +228,6 @@ async function runLocalInit(config) {
|
|
|
235
228
|
console.log(` ${step}`);
|
|
236
229
|
}
|
|
237
230
|
|
|
238
|
-
const sdkKey = resolveAccountSdkKey({ env: process.env }).value;
|
|
239
|
-
if (prompt && sdkKey) {
|
|
240
|
-
console.log('\n Optional — BYOK keys for IAM dashboard Agent Sam (skip with Enter):\n');
|
|
241
|
-
await promptOptionalByokKeys(sdkKey, prompt);
|
|
242
|
-
}
|
|
243
231
|
|
|
244
232
|
console.log(`
|
|
245
233
|
Local means local: no Worker, tunnel, IAM login, or cloud database is required.
|
|
@@ -291,17 +279,12 @@ async function initInteractive(partial = {}) {
|
|
|
291
279
|
if (runTarget !== 'local') {
|
|
292
280
|
const { detectContext, missingForInit } = await import('./lib/detect-context.js');
|
|
293
281
|
const ctx = await detectContext();
|
|
294
|
-
if (missingForInit(ctx,
|
|
282
|
+
if (missingForInit(ctx, resolveAccountAuth({ env: process.env }).value, { runTarget }).length) {
|
|
295
283
|
printContextSummary(ctx);
|
|
296
284
|
}
|
|
297
285
|
}
|
|
298
286
|
|
|
299
|
-
|
|
300
|
-
try {
|
|
301
|
-
await runLocalInit({ projectName, lane: laneKey, runTarget, prompt });
|
|
302
|
-
} finally {
|
|
303
|
-
prompt?.close();
|
|
304
|
-
}
|
|
287
|
+
await runLocalInit({ projectName, lane: laneKey, runTarget, prompt: null });
|
|
305
288
|
outro(`Created ${projectName}`);
|
|
306
289
|
}
|
|
307
290
|
|
|
@@ -387,6 +370,13 @@ if (command === '--version' || command === '-v') {
|
|
|
387
370
|
reportCliError(e);
|
|
388
371
|
process.exit(1);
|
|
389
372
|
}
|
|
373
|
+
} else if (command === 'providers') {
|
|
374
|
+
try {
|
|
375
|
+
await runProviders(rest);
|
|
376
|
+
} catch (e) {
|
|
377
|
+
reportCliError(e);
|
|
378
|
+
process.exit(1);
|
|
379
|
+
}
|
|
390
380
|
} else if (command === 'env') {
|
|
391
381
|
try {
|
|
392
382
|
await runEnv(rest);
|
|
@@ -11,7 +11,7 @@ export async function runLogin(argv = [], options = {}) {
|
|
|
11
11
|
const write = options.write || ((text) => process.stdout.write(text));
|
|
12
12
|
const authenticate = options.authenticateImpl || authenticateViaBrowser;
|
|
13
13
|
const session = await authenticate();
|
|
14
|
-
if (!String(session?.access_token || '').trim()
|
|
14
|
+
if (!String(session?.access_token || '').trim()) throw new Error('Agent Sam login did not return a browser session credential');
|
|
15
15
|
// authenticateViaBrowser persists by default. Keep injected transports/test flows equivalent.
|
|
16
16
|
if (!readAccountSession({ home: options.home })) saveAccountSession(session, { home: options.home });
|
|
17
17
|
const status = await collectWhoami({ home: options.home, env: options.env || process.env, contextLoader: options.contextLoader });
|
package/src/commands/deploy.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import readline from 'node:readline';
|
|
7
7
|
import { authenticateViaBrowser } from '../lib/auth.js';
|
|
8
8
|
import { getJson, streamScaffold } from '../lib/core-client.js';
|
|
9
|
-
import {
|
|
9
|
+
import { resolveAccountAuth } from '../lib/account-session.js';
|
|
10
10
|
import { getDefaultProfile, getDeployTarget, getLocalSchemaPath, getProjectName, getProjectPreset, readProjectConfig, setDeployTarget, writeProjectConfig } from '../lib/project-config.js';
|
|
11
11
|
import { isLocalStudioCheckout, runLocalStudioDeploy } from '../lib/deploy/local-studio.js';
|
|
12
12
|
|
|
@@ -68,7 +68,7 @@ function ask(question) {
|
|
|
68
68
|
async function runCloudflareDeploy(cwd, config, accountId) {
|
|
69
69
|
console.log('\n Cloudflare deploy — browser sign-in + resource provisioning…\n');
|
|
70
70
|
|
|
71
|
-
let token =
|
|
71
|
+
let token = resolveAccountAuth({ env: process.env }).value;
|
|
72
72
|
if (!token) {
|
|
73
73
|
const session = await authenticateViaBrowser();
|
|
74
74
|
token = session.access_token;
|