@alpacakit/agents-conventions 0.1.0-beta.36 → 0.1.0-beta.39
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 +130 -10
- package/dist/cli-output.d.ts +209 -0
- package/dist/cli-output.d.ts.map +1 -0
- package/dist/cli-output.js +208 -0
- package/dist/cli.d.ts +750 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +388 -0
- package/dist/home.d.ts +65 -0
- package/dist/home.d.ts.map +1 -0
- package/dist/home.js +105 -0
- package/dist/index.d.ts +23 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -56
- package/dist/names.d.ts +38 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +41 -0
- package/dist/paths.d.ts +41 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +72 -0
- package/dist/register.d.ts +122 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +212 -0
- package/dist/remove.d.ts +40 -0
- package/dist/remove.d.ts.map +1 -0
- package/dist/remove.js +73 -0
- package/dist/values.d.ts +30 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +28 -0
- package/package.json +15 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../src/remove.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,YAAY,CAAC;AAGvE,eAAO,MAAM,+BAA+B;;;;CAIlC,CAAC;AAEX,MAAM,MAAM,0BAA0B,GAAG,eAAe,GAAG;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GACnC;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,+BAA+B,CAAC,cAAc,CAAC;IACrE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,+BAA+B,CAAC,kBAAkB,CAAC;IACzE,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,+BAA+B,CAAC,QAAQ,CAAC;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,GACD,iBAAiB,CAAC;AAEtB;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,2BAA2B,CAAC,CAyBtC"}
|
package/dist/remove.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one way an agent leaves the shared home. `name` is a record name, the
|
|
3
|
+
* same position `connection login <name>` uses, and profiles win over agent
|
|
4
|
+
* configs because a profile is the more specific thing an operator names.
|
|
5
|
+
*/
|
|
6
|
+
import { rm } from "node:fs/promises";
|
|
7
|
+
import { AUTH_MATERIAL_KIND } from "@alpacakit/agents";
|
|
8
|
+
import { openAgentsHome } from "./home.js";
|
|
9
|
+
import { rejectInvalidName } from "./names.js";
|
|
10
|
+
import { createKeyringSecretRef, isManagedHomePath } from "./paths.js";
|
|
11
|
+
export const REMOVE_AGENTS_HOME_ENTRY_RESULT = {
|
|
12
|
+
removedProfile: "removed_profile",
|
|
13
|
+
removedAgentConfig: "removed_agent_config",
|
|
14
|
+
notFound: "not_found",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The record goes first, then the credential it pointed at: if deleting the
|
|
18
|
+
* credential fails the operator is left with an inert directory or an orphaned
|
|
19
|
+
* keychain entry and a loud error — never with a live record pointing at a
|
|
20
|
+
* credential that is already gone.
|
|
21
|
+
*
|
|
22
|
+
* Only artifacts this package created are deleted. A home the operator pointed
|
|
23
|
+
* at themselves, or a secret behind someone else's resolver, is theirs.
|
|
24
|
+
*/
|
|
25
|
+
export async function removeAgentsHomeEntry(input) {
|
|
26
|
+
// Nothing this package created can carry a name outside the grammar, so a
|
|
27
|
+
// name outside it cannot match a record — and must never reach the delete.
|
|
28
|
+
const invalidName = rejectInvalidName(input.name);
|
|
29
|
+
if (invalidName !== null) {
|
|
30
|
+
return invalidName;
|
|
31
|
+
}
|
|
32
|
+
const home = openAgentsHome(input);
|
|
33
|
+
const profile = await home.config.profiles.remove(input.name);
|
|
34
|
+
if (profile !== null) {
|
|
35
|
+
return {
|
|
36
|
+
kind: REMOVE_AGENTS_HOME_ENTRY_RESULT.removedProfile,
|
|
37
|
+
profile,
|
|
38
|
+
removedManagedHome: await removeManagedHome(home.agentsHome, profile),
|
|
39
|
+
removedSecret: await removeManagedSecret(home.keyring, profile),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const agentConfig = await home.config.agentConfigs.remove(input.name);
|
|
43
|
+
if (agentConfig !== null) {
|
|
44
|
+
return {
|
|
45
|
+
kind: REMOVE_AGENTS_HOME_ENTRY_RESULT.removedAgentConfig,
|
|
46
|
+
agentConfig,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return { kind: REMOVE_AGENTS_HOME_ENTRY_RESULT.notFound, name: input.name };
|
|
50
|
+
}
|
|
51
|
+
async function removeManagedHome(agentsHome, profile) {
|
|
52
|
+
if (profile.material.kind !== AUTH_MATERIAL_KIND.homeDir) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const { path } = profile.material;
|
|
56
|
+
if (!isManagedHomePath({ rootDir: agentsHome, profileId: profile.id, path })) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
await rm(path, { recursive: true, force: true });
|
|
60
|
+
return path;
|
|
61
|
+
}
|
|
62
|
+
async function removeManagedSecret(keyring, profile) {
|
|
63
|
+
if (profile.material.kind !== AUTH_MATERIAL_KIND.apiKey) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const managed = createKeyringSecretRef(profile.id);
|
|
67
|
+
const { secret } = profile.material;
|
|
68
|
+
if (secret.resolver !== managed.resolver || secret.id !== managed.id) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
await keyring.delete(secret.id);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
package/dist/values.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family vocabulary, spelled once. Every constant here is a decision
|
|
3
|
+
* about WHERE shared agent state lives on a machine — the one thing every
|
|
4
|
+
* AlpacaKit-family product must agree on to see the same agents.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AGENTS_HOME_ENV_VAR = "ALPACA_AGENTS_HOME";
|
|
7
|
+
export declare const AGENTS_HOME_DIRECTORY = ".alpaca/agents";
|
|
8
|
+
/** Keychain service for agent credentials — distinct from integrations (I1). */
|
|
9
|
+
export declare const AGENTS_KEYRING_SERVICE = "alpaca.agents";
|
|
10
|
+
export declare const AGENTS_KEYRING_RESOLVER = "agents-home-keyring";
|
|
11
|
+
/** Login homes this package creates, and is therefore allowed to delete. */
|
|
12
|
+
export declare const AGENTS_MANAGED_HOMES_DIRECTORY = "managed-homes";
|
|
13
|
+
export declare const AGENTS_KEYRING_ACCOUNT: {
|
|
14
|
+
readonly prefix: "profile";
|
|
15
|
+
readonly apiKeySuffix: "api-key";
|
|
16
|
+
readonly separator: ":";
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Which agent kinds an operator can add to the shared home. Deciding this is
|
|
20
|
+
* the family's job, not a product's, so the vocabulary lives beside the
|
|
21
|
+
* procedure that acts on it — `./cli` only spells it as a flag.
|
|
22
|
+
*
|
|
23
|
+
* A literal, because `AGENT_CONFIG_KIND` values are branded and cannot be a
|
|
24
|
+
* CLI enum; a test pins the two together so they cannot drift.
|
|
25
|
+
*/
|
|
26
|
+
export declare const AGENT_ADD_KIND: {
|
|
27
|
+
readonly openaiCompatible: "openai-compatible";
|
|
28
|
+
};
|
|
29
|
+
export type AgentAddKind = (typeof AGENT_ADD_KIND)[keyof typeof AGENT_ADD_KIND];
|
|
30
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../src/values.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AACtD,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AACtD,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAC7D,4EAA4E;AAC5E,eAAO,MAAM,8BAA8B,kBAAkB,CAAC;AAC9D,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAC;AAEX;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;CAEjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC"}
|
package/dist/values.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family vocabulary, spelled once. Every constant here is a decision
|
|
3
|
+
* about WHERE shared agent state lives on a machine — the one thing every
|
|
4
|
+
* AlpacaKit-family product must agree on to see the same agents.
|
|
5
|
+
*/
|
|
6
|
+
export const AGENTS_HOME_ENV_VAR = "ALPACA_AGENTS_HOME";
|
|
7
|
+
export const AGENTS_HOME_DIRECTORY = ".alpaca/agents";
|
|
8
|
+
/** Keychain service for agent credentials — distinct from integrations (I1). */
|
|
9
|
+
export const AGENTS_KEYRING_SERVICE = "alpaca.agents";
|
|
10
|
+
export const AGENTS_KEYRING_RESOLVER = "agents-home-keyring";
|
|
11
|
+
/** Login homes this package creates, and is therefore allowed to delete. */
|
|
12
|
+
export const AGENTS_MANAGED_HOMES_DIRECTORY = "managed-homes";
|
|
13
|
+
export const AGENTS_KEYRING_ACCOUNT = {
|
|
14
|
+
prefix: "profile",
|
|
15
|
+
apiKeySuffix: "api-key",
|
|
16
|
+
separator: ":",
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Which agent kinds an operator can add to the shared home. Deciding this is
|
|
20
|
+
* the family's job, not a product's, so the vocabulary lives beside the
|
|
21
|
+
* procedure that acts on it — `./cli` only spells it as a flag.
|
|
22
|
+
*
|
|
23
|
+
* A literal, because `AGENT_CONFIG_KIND` values are branded and cannot be a
|
|
24
|
+
* CLI enum; a test pins the two together so they cannot drift.
|
|
25
|
+
*/
|
|
26
|
+
export const AGENT_ADD_KIND = {
|
|
27
|
+
openaiCompatible: "openai-compatible",
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alpacakit/agents-conventions",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
4
|
-
"description": "AlpacaKit-family conventions for @alpacakit/agents machine-local config (paths, keyring, managed homes).",
|
|
3
|
+
"version": "0.1.0-beta.39",
|
|
4
|
+
"description": "AlpacaKit-family conventions for @alpacakit/agents machine-local config (paths, keyring, managed homes) and the shared `agent` command surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./cli": {
|
|
17
|
+
"types": "./dist/cli.d.ts",
|
|
18
|
+
"import": "./dist/cli.js"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"types": "./dist/index.d.ts",
|
|
@@ -21,11 +25,18 @@
|
|
|
21
25
|
"LICENSE"
|
|
22
26
|
],
|
|
23
27
|
"dependencies": {
|
|
24
|
-
"@alpacakit/agents": "0.1.0-beta.
|
|
28
|
+
"@alpacakit/agents": "0.1.0-beta.39",
|
|
29
|
+
"@alpacakit/core": "0.1.0-beta.39"
|
|
25
30
|
},
|
|
26
31
|
"devDependencies": {
|
|
27
32
|
"typescript": "^5.9.3",
|
|
28
|
-
"vitest": "^4.0.18"
|
|
33
|
+
"vitest": "^4.0.18",
|
|
34
|
+
"zod": "4.3.6",
|
|
35
|
+
"@alpacakit/channels": "0.1.0-beta.39"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"zod": "^4.3.6",
|
|
39
|
+
"@alpacakit/channels": "^0.1.0-beta.39"
|
|
29
40
|
},
|
|
30
41
|
"scripts": {
|
|
31
42
|
"build": "tsc -p tsconfig.build.json",
|