@ouro.bot/friends 0.1.0-alpha.4
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/LICENSE +201 -0
- package/README.md +514 -0
- package/changelog.json +34 -0
- package/dist/a2a/index.d.ts +102 -0
- package/dist/a2a/index.js +198 -0
- package/dist/agent-peer.d.ts +17 -0
- package/dist/agent-peer.js +57 -0
- package/dist/channel.d.ts +11 -0
- package/dist/channel.js +132 -0
- package/dist/consent.d.ts +34 -0
- package/dist/consent.js +62 -0
- package/dist/coordination.d.ts +100 -0
- package/dist/coordination.js +255 -0
- package/dist/file-bundle.d.ts +12 -0
- package/dist/file-bundle.js +23 -0
- package/dist/grant-store-file.d.ts +16 -0
- package/dist/grant-store-file.js +136 -0
- package/dist/grant-store.d.ts +7 -0
- package/dist/grant-store.js +8 -0
- package/dist/grants.d.ts +39 -0
- package/dist/grants.js +84 -0
- package/dist/group-context.d.ts +21 -0
- package/dist/group-context.js +144 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +105 -0
- package/dist/link-identity.d.ts +14 -0
- package/dist/link-identity.js +88 -0
- package/dist/mcp/bin.d.ts +2 -0
- package/dist/mcp/bin.js +16 -0
- package/dist/mcp/dispatch.d.ts +14 -0
- package/dist/mcp/dispatch.js +432 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.js +14 -0
- package/dist/mcp/run-main.d.ts +7 -0
- package/dist/mcp/run-main.js +45 -0
- package/dist/mcp/schemas.d.ts +10 -0
- package/dist/mcp/schemas.js +398 -0
- package/dist/mcp/server.d.ts +21 -0
- package/dist/mcp/server.js +194 -0
- package/dist/mission-share.d.ts +94 -0
- package/dist/mission-share.js +232 -0
- package/dist/mission-store-file.d.ts +18 -0
- package/dist/mission-store-file.js +153 -0
- package/dist/mission-store.d.ts +10 -0
- package/dist/mission-store.js +9 -0
- package/dist/missions.d.ts +31 -0
- package/dist/missions.js +98 -0
- package/dist/notes.d.ts +11 -0
- package/dist/notes.js +90 -0
- package/dist/observability.d.ts +27 -0
- package/dist/observability.js +31 -0
- package/dist/outcomes.d.ts +9 -0
- package/dist/outcomes.js +51 -0
- package/dist/resolver.d.ts +28 -0
- package/dist/resolver.js +187 -0
- package/dist/results.d.ts +8 -0
- package/dist/results.js +2 -0
- package/dist/room.d.ts +22 -0
- package/dist/room.js +40 -0
- package/dist/share.d.ts +106 -0
- package/dist/share.js +223 -0
- package/dist/standing.d.ts +83 -0
- package/dist/standing.js +111 -0
- package/dist/store-file.d.ts +21 -0
- package/dist/store-file.js +264 -0
- package/dist/store.d.ts +9 -0
- package/dist/store.js +4 -0
- package/dist/tokens.d.ts +8 -0
- package/dist/tokens.js +26 -0
- package/dist/trust-explanation.d.ts +16 -0
- package/dist/trust-explanation.js +74 -0
- package/dist/trust-mutation.d.ts +4 -0
- package/dist/trust-mutation.js +29 -0
- package/dist/types.d.ts +164 -0
- package/dist/types.js +51 -0
- package/dist/util/cap-string.d.ts +7 -0
- package/dist/util/cap-string.js +35 -0
- package/dist/verifier.d.ts +11 -0
- package/dist/verifier.js +29 -0
- package/dist/whoami.d.ts +7 -0
- package/dist/whoami.js +39 -0
- package/package.json +68 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// String-capping helper, copied verbatim from the harness's
|
|
3
|
+
// `heart/session-events.ts` (`capStructuredRecordString` +
|
|
4
|
+
// `truncateLargeEventContent` + `EVENT_CONTENT_MAX_CHARS`).
|
|
5
|
+
//
|
|
6
|
+
// Used by FileFriendStore to bound the size of free-text note values before they
|
|
7
|
+
// are written to disk, so a single runaway note can't bloat a friend record.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.EVENT_CONTENT_MAX_CHARS = void 0;
|
|
10
|
+
exports.truncateLargeEventContent = truncateLargeEventContent;
|
|
11
|
+
exports.capStructuredRecordString = capStructuredRecordString;
|
|
12
|
+
exports.EVENT_CONTENT_MAX_CHARS = 256 * 1024;
|
|
13
|
+
function truncateLargeEventContent(content, maxChars) {
|
|
14
|
+
/* v8 ignore next 3 -- copied verbatim from the harness; the non-string guard is
|
|
15
|
+
unreachable through this package's API (note values are typed `string`) but is
|
|
16
|
+
kept so the harness can drop in its real emitter without behavior drift @preserve */
|
|
17
|
+
if (typeof content !== "string") {
|
|
18
|
+
return { content, truncated: false, originalLength: 0 };
|
|
19
|
+
}
|
|
20
|
+
if (content.length <= maxChars) {
|
|
21
|
+
return { content, truncated: false, originalLength: content.length };
|
|
22
|
+
}
|
|
23
|
+
const marker = `[truncated — event content exceeded ${maxChars} chars; original length ${content.length} chars]`;
|
|
24
|
+
const remainingBudget = Math.max(0, maxChars - marker.length);
|
|
25
|
+
const headLength = Math.ceil(remainingBudget * 0.75);
|
|
26
|
+
const tailLength = Math.max(0, remainingBudget - headLength);
|
|
27
|
+
return {
|
|
28
|
+
content: `${content.slice(0, headLength)}${marker}${tailLength > 0 ? content.slice(-tailLength) : ""}`,
|
|
29
|
+
truncated: true,
|
|
30
|
+
originalLength: content.length,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function capStructuredRecordString(value) {
|
|
34
|
+
return truncateLargeEventContent(value, exports.EVENT_CONTENT_MAX_CHARS).content;
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface AgentVerifier {
|
|
2
|
+
/** Whether `fromAgentId` is who it claims to be. `proof` is an opaque,
|
|
3
|
+
* verifier-specific credential (a signature, a VC, …); the TOFU default
|
|
4
|
+
* ignores it. */
|
|
5
|
+
verify(fromAgentId: string, proof?: string): boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Trust-on-first-use: accept any peer, ignore `proof`. The day-one default; the
|
|
8
|
+
* trust LADDER (not the wire) is what caps what a peer's claims are worth. */
|
|
9
|
+
export declare const tofuVerifier: AgentVerifier;
|
|
10
|
+
/** The default verifier used by `importProfileShare` when none is injected. */
|
|
11
|
+
export declare const DEFAULT_AGENT_VERIFIER: AgentVerifier;
|
package/dist/verifier.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_AGENT_VERIFIER = exports.tofuVerifier = void 0;
|
|
4
|
+
// AgentVerifier — Fork B. The pluggable authentication seam.
|
|
5
|
+
//
|
|
6
|
+
// The package does AUTHORIZATION (how much a verified peer's claims count, via
|
|
7
|
+
// the trust ladder). AUTHENTICATION of the wire is the caller's job — the same
|
|
8
|
+
// split that kept the A2A card-fetch harness-side. This interface is the seam: a
|
|
9
|
+
// caller can plug in DID/VC verification later. The default is trust-on-first-use
|
|
10
|
+
// (TOFU): it accepts any peer and ignores `proof`, matching upsertAgentPeer's
|
|
11
|
+
// onboard-on-first-contact behavior. The `proof?` slot is reserved on the
|
|
12
|
+
// envelope from day one so a stronger verifier can be dropped in without an
|
|
13
|
+
// envelope change.
|
|
14
|
+
const observability_1 = require("./observability");
|
|
15
|
+
/** Trust-on-first-use: accept any peer, ignore `proof`. The day-one default; the
|
|
16
|
+
* trust LADDER (not the wire) is what caps what a peer's claims are worth. */
|
|
17
|
+
exports.tofuVerifier = {
|
|
18
|
+
verify(fromAgentId) {
|
|
19
|
+
(0, observability_1.emitNervesEvent)({
|
|
20
|
+
component: "friends",
|
|
21
|
+
event: "friends.agent_verified",
|
|
22
|
+
message: "verified agent (tofu)",
|
|
23
|
+
meta: { fromAgentId },
|
|
24
|
+
});
|
|
25
|
+
return true;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/** The default verifier used by `importProfileShare` when none is injected. */
|
|
29
|
+
exports.DEFAULT_AGENT_VERIFIER = exports.tofuVerifier;
|
package/dist/whoami.d.ts
ADDED
package/dist/whoami.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.whoami = whoami;
|
|
4
|
+
// whoami — "who am I?" self-resolution over a friend store.
|
|
5
|
+
//
|
|
6
|
+
// D5 heuristic: the machine owner is the OS user running the process. The self
|
|
7
|
+
// friend is the record whose externalIds include a `local` entry matching the
|
|
8
|
+
// owner username (bare or `user@host`); if none matches by local id, the first
|
|
9
|
+
// `family` friend is used as a fallback. When the owner is undetectable, or no
|
|
10
|
+
// friend matches, only `machineOwner` is returned (no self fields).
|
|
11
|
+
const resolver_1 = require("./resolver");
|
|
12
|
+
const observability_1 = require("./observability");
|
|
13
|
+
async function whoami(store) {
|
|
14
|
+
const machineOwner = (0, resolver_1.machineOwnerUsername)();
|
|
15
|
+
if (typeof store.listAll !== "function") {
|
|
16
|
+
(0, observability_1.emitNervesEvent)({
|
|
17
|
+
component: "friends",
|
|
18
|
+
event: "friends.whoami",
|
|
19
|
+
message: "resolved machine owner self",
|
|
20
|
+
meta: { hasSelf: false },
|
|
21
|
+
});
|
|
22
|
+
return { machineOwner };
|
|
23
|
+
}
|
|
24
|
+
const all = await store.listAll();
|
|
25
|
+
let self;
|
|
26
|
+
if (machineOwner) {
|
|
27
|
+
self = all.find((f) => f.externalIds.some((e) => (0, resolver_1.isLocalMachineOwnerIdentity)(e.provider, e.externalId, machineOwner)));
|
|
28
|
+
self ??= all.find((f) => f.trustLevel === "family");
|
|
29
|
+
}
|
|
30
|
+
(0, observability_1.emitNervesEvent)({
|
|
31
|
+
component: "friends",
|
|
32
|
+
event: "friends.whoami",
|
|
33
|
+
message: "resolved machine owner self",
|
|
34
|
+
meta: { hasSelf: Boolean(self) },
|
|
35
|
+
});
|
|
36
|
+
return self
|
|
37
|
+
? { machineOwner, selfFriendId: self.id, selfAgentName: self.name }
|
|
38
|
+
: { machineOwner };
|
|
39
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ouro.bot/friends",
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
|
+
"description": "The who's-who / identity / relationship substrate for agents — trust ladder (family/friend/acquaintance/stranger), multi-party and multi-agent, consumed via the FriendStore interface + FriendResolver.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./mcp": {
|
|
14
|
+
"types": "./dist/mcp/index.d.ts",
|
|
15
|
+
"default": "./dist/mcp/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./a2a": {
|
|
18
|
+
"types": "./dist/a2a/index.d.ts",
|
|
19
|
+
"default": "./dist/a2a/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"friends-mcp": "./dist/mcp/bin.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/",
|
|
27
|
+
"changelog.json"
|
|
28
|
+
],
|
|
29
|
+
"type": "commonjs",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"prepare": "npm run build",
|
|
33
|
+
"pretest": "npm run build",
|
|
34
|
+
"pretest:coverage": "npm run build",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:coverage": "vitest run --coverage",
|
|
37
|
+
"lint": "eslint src/",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"example:cross-agent-moat": "npm run build && tsx examples/cross-agent-moat.ts",
|
|
40
|
+
"example:a2a-git-mailbox": "npm run build && tsx examples/a2a-git-mailbox.ts",
|
|
41
|
+
"example:cross-agent-mission-memory": "npm run build && tsx examples/cross-agent-mission-memory.ts",
|
|
42
|
+
"example:cross-agent-standing": "npm run build && tsx examples/cross-agent-standing.ts",
|
|
43
|
+
"example:cross-agent-coordination": "npm run build && tsx examples/cross-agent-coordination.ts",
|
|
44
|
+
"release:bump": "node scripts/release-bump.cjs",
|
|
45
|
+
"release:preflight": "node scripts/release-preflight.cjs",
|
|
46
|
+
"release:trust:check": "node scripts/npm-trusted-publishers.cjs check",
|
|
47
|
+
"release:trust:repair-plan": "node scripts/npm-trusted-publishers.cjs repair-plan",
|
|
48
|
+
"release:trust:repair": "node scripts/npm-trusted-publishers.cjs repair"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/ourostack/friends.git"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^22.0.0",
|
|
60
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
61
|
+
"eslint": "^10.0.2",
|
|
62
|
+
"semver": "^7.6.0",
|
|
63
|
+
"tsx": "^4.22.4",
|
|
64
|
+
"typescript": "^5.7.0",
|
|
65
|
+
"typescript-eslint": "^8.56.1",
|
|
66
|
+
"vitest": "^4.1.8"
|
|
67
|
+
}
|
|
68
|
+
}
|