patchr 0.1.0__py3-none-any.whl
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.
- apps/__init__.py +2 -0
- apps/api/__init__.py +2 -0
- apps/api/main.py +652 -0
- apps/benchmarks/__init__.py +1 -0
- apps/benchmarks/main.py +20 -0
- apps/sandbox/__init__.py +1 -0
- apps/sandbox/main.py +20 -0
- apps/worker/__init__.py +2 -0
- apps/worker/main.py +15 -0
- apps/worker/verify.py +14 -0
- patchr/__init__.py +12 -0
- patchr/sdk/__init__.py +20 -0
- patchr/sdk/client.py +12 -0
- patchr-0.1.0.dist-info/METADATA +137 -0
- patchr-0.1.0.dist-info/RECORD +116 -0
- patchr-0.1.0.dist-info/WHEEL +5 -0
- patchr-0.1.0.dist-info/entry_points.txt +5 -0
- patchr-0.1.0.dist-info/licenses/LICENSE +17 -0
- patchr-0.1.0.dist-info/top_level.txt +3 -0
- picux/__init__.py +6 -0
- picux/agents/__init__.py +5 -0
- picux/agents/registry.py +204 -0
- picux/api/__init__.py +5 -0
- picux/api/service.py +5075 -0
- picux/audit/__init__.py +31 -0
- picux/audit/activity.py +97 -0
- picux/audit/observability.py +55 -0
- picux/audit/verification/__init__.py +21 -0
- picux/audit/verification/ledger.py +633 -0
- picux/benchmarks/__init__.py +5 -0
- picux/benchmarks/local.py +286 -0
- picux/config.py +140 -0
- picux/contracts/__init__.py +22 -0
- picux/contracts/handshake.py +122 -0
- picux/contracts/integration.py +385 -0
- picux/contracts/openapi.py +187 -0
- picux/contracts/protocol_map.py +152 -0
- picux/contracts/routes.py +980 -0
- picux/contracts/schema_catalog.py +125 -0
- picux/core/__init__.py +17 -0
- picux/core/models.py +148 -0
- picux/core/router.py +131 -0
- picux/core/runtime.py +42 -0
- picux/core/state_machine.py +38 -0
- picux/domains/__init__.py +2 -0
- picux/domains/bridge/HostRun.py +1104 -0
- picux/domains/bridge/__init__.py +6 -0
- picux/domains/bridge/engine.py +345 -0
- picux/domains/hunt/__init__.py +6 -0
- picux/domains/hunt/engine.py +307 -0
- picux/domains/hunt/models.py +88 -0
- picux/domains/pay/__init__.py +16 -0
- picux/domains/pay/adapters.py +607 -0
- picux/domains/pay/engine.py +950 -0
- picux/domains/pay/models.py +95 -0
- picux/domains/proxy/__init__.py +5 -0
- picux/domains/proxy/engine.py +466 -0
- picux/domains/resolve/__init__.py +5 -0
- picux/domains/resolve/engine.py +546 -0
- picux/orchestrator/__init__.py +3 -0
- picux/orchestrator/engine.py +2840 -0
- picux/portals/__init__.py +17 -0
- picux/portals/templates.py +272 -0
- picux/protocols/__init__.py +1 -0
- picux/protocols/a2a/__init__.py +6 -0
- picux/protocols/a2a/client.py +51 -0
- picux/protocols/a2a/envelope.py +132 -0
- picux/protocols/mcp/__init__.py +7 -0
- picux/protocols/mcp/client.py +69 -0
- picux/protocols/mcp/contract.py +67 -0
- picux/protocols/mcp/server.py +76 -0
- picux/sandbox/__init__.py +6 -0
- picux/sandbox/midnight_arbitrage.py +215 -0
- picux/sandbox/models.py +90 -0
- picux/sdk/__init__.py +13 -0
- picux/sdk/client.py +768 -0
- picux/sdk/external.py +245 -0
- picux/security/__init__.py +18 -0
- picux/security/auth.py +86 -0
- picux/security/config_validator.py +58 -0
- picux/security/policy.py +158 -0
- picux/security/secrets.py +144 -0
- picux/signals/__init__.py +1 -0
- picux/signals/community/__init__.py +24 -0
- picux/signals/community/adapters/__init__.py +7 -0
- picux/signals/community/adapters/reddit.py +37 -0
- picux/signals/community/adapters/shopify.py +23 -0
- picux/signals/community/adapters/web.py +23 -0
- picux/signals/community/disambiguation.py +51 -0
- picux/signals/community/intake.py +227 -0
- picux/signals/community/models.py +102 -0
- picux/signals/community/rules.py +91 -0
- picux/signals/community/scoring.py +64 -0
- picux/storage/__init__.py +41 -0
- picux/storage/agents.py +50 -0
- picux/storage/cases.py +440 -0
- picux/storage/channels.py +476 -0
- picux/storage/connectors.py +411 -0
- picux/storage/envelopes.py +137 -0
- picux/storage/escrows.py +168 -0
- picux/storage/events.py +989 -0
- picux/storage/keyspace.py +60 -0
- picux/storage/mandates.py +107 -0
- picux/storage/portals.py +222 -0
- picux/storage/postgres.py +2049 -0
- picux/storage/providers.py +148 -0
- picux/storage/proxy.py +231 -0
- picux/storage/receipts.py +131 -0
- picux/storage/signals.py +147 -0
- picux/storage/tasks.py +179 -0
- picux/tools/__init__.py +11 -0
- picux/tools/shared.py +2048 -0
- picux/verification/__init__.py +5 -0
- picux/verification/rollout.py +183 -0
- picux/workflows/__init__.py +5 -0
- picux/workflows/templates.py +74 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
from picux.signals.community.models import SignalEntity
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class EntityRule:
|
|
11
|
+
entity: SignalEntity
|
|
12
|
+
label: str
|
|
13
|
+
aliases: tuple[str, ...]
|
|
14
|
+
canonical: str
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
CANONICAL_QUERIES = (
|
|
18
|
+
"Picux Protocol",
|
|
19
|
+
"Picux Pay",
|
|
20
|
+
"Picux agentic infrastructure",
|
|
21
|
+
"Picux agent deployment",
|
|
22
|
+
"Picux MCP",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
ENTITY_RULES = (
|
|
26
|
+
EntityRule(
|
|
27
|
+
entity=SignalEntity.PICUX,
|
|
28
|
+
label="Picux",
|
|
29
|
+
canonical="Picux Protocol",
|
|
30
|
+
aliases=("picux", "picux protocol", "picux pay", "picux.io", "picux.network"),
|
|
31
|
+
),
|
|
32
|
+
EntityRule(
|
|
33
|
+
entity=SignalEntity.EXTERNAL_APP,
|
|
34
|
+
label="External App",
|
|
35
|
+
canonical="External App",
|
|
36
|
+
aliases=("external app", "external service", "external agent", "powered by picux"),
|
|
37
|
+
),
|
|
38
|
+
EntityRule(
|
|
39
|
+
entity=SignalEntity.LEGACY_SWARM,
|
|
40
|
+
label="The Swarm",
|
|
41
|
+
canonical="The Swarm",
|
|
42
|
+
aliases=("the swarm", "the swarm core", "swarm core"),
|
|
43
|
+
),
|
|
44
|
+
EntityRule(
|
|
45
|
+
entity=SignalEntity.HARNESS,
|
|
46
|
+
label="Harness",
|
|
47
|
+
canonical="Harness",
|
|
48
|
+
aliases=("harness", "harness ai", "harness swarm", "harness agents", "harness.io"),
|
|
49
|
+
),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
PLATFORM_WEIGHTS = {
|
|
53
|
+
"reddit": 0.12,
|
|
54
|
+
"web": 0.10,
|
|
55
|
+
"shopify": 0.08,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
LAUNCH_DOMAINS = ("hunt", "resolve", "bridge")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def normalizeText(value: str) -> str:
|
|
62
|
+
lowered = str(value or "").lower()
|
|
63
|
+
normalized = re.sub(r"[^a-z0-9]+", " ", lowered)
|
|
64
|
+
compact = re.sub(r"\s+", " ", normalized).strip()
|
|
65
|
+
return f" {compact} "
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def phraseHits(text: str, phrases: tuple[str, ...] | list[str]) -> tuple[str, ...]:
|
|
69
|
+
normalized = normalizeText(text)
|
|
70
|
+
hits: list[str] = []
|
|
71
|
+
for phrase in phrases:
|
|
72
|
+
normalizedPhrase = normalizeText(phrase).strip()
|
|
73
|
+
if not normalizedPhrase:
|
|
74
|
+
continue
|
|
75
|
+
pattern = rf"(?<![a-z0-9]){re.escape(normalizedPhrase)}(?![a-z0-9])"
|
|
76
|
+
if re.search(pattern, normalized):
|
|
77
|
+
hits.append(str(phrase))
|
|
78
|
+
return tuple(dict.fromkeys(hits))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def entityCatalog() -> list[dict[str, object]]:
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
"entity": rule.entity.value,
|
|
85
|
+
"label": rule.label,
|
|
86
|
+
"canonical": rule.canonical,
|
|
87
|
+
"aliases": list(rule.aliases),
|
|
88
|
+
"external": rule.entity == SignalEntity.HARNESS,
|
|
89
|
+
}
|
|
90
|
+
for rule in ENTITY_RULES
|
|
91
|
+
]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from picux.signals.community.disambiguation import inspectSignalEntity
|
|
4
|
+
from picux.signals.community.models import CommunitySignal, SignalAnalysis, SignalEntity
|
|
5
|
+
from picux.signals.community.rules import CANONICAL_QUERIES, LAUNCH_DOMAINS, PLATFORM_WEIGHTS, phraseHits
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
ENTITY_BASE = {
|
|
9
|
+
SignalEntity.PICUX: 0.55,
|
|
10
|
+
SignalEntity.EXTERNAL_APP: 0.45,
|
|
11
|
+
SignalEntity.LEGACY_SWARM: 0.25,
|
|
12
|
+
SignalEntity.HARNESS: 0.0,
|
|
13
|
+
SignalEntity.UNKNOWN: 0.05,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def scoreSignal(signal: CommunitySignal | dict[str, object]) -> SignalAnalysis:
|
|
18
|
+
item = signal if isinstance(signal, CommunitySignal) else CommunitySignal.fromObj(signal)
|
|
19
|
+
sourceText = " ".join([item.text, item.query, item.source.url, item.source.community])
|
|
20
|
+
detail = inspectSignalEntity(sourceText)
|
|
21
|
+
entity = detail["entity"]
|
|
22
|
+
queryHits = phraseHits(sourceText, CANONICAL_QUERIES)
|
|
23
|
+
reasons: list[str] = [f"entity:{entity.value}"]
|
|
24
|
+
matches = tuple(dict.fromkeys([*detail["matches"], *queryHits]))
|
|
25
|
+
negativeMatches = tuple(detail["harnessMatches"])
|
|
26
|
+
|
|
27
|
+
confidence = ENTITY_BASE[entity]
|
|
28
|
+
platform = item.source.platform.lower()
|
|
29
|
+
sourceBoost = PLATFORM_WEIGHTS.get(platform, 0.04 if platform else 0.0)
|
|
30
|
+
if entity != SignalEntity.HARNESS:
|
|
31
|
+
confidence += sourceBoost
|
|
32
|
+
if platform:
|
|
33
|
+
reasons.append(f"source:{platform}")
|
|
34
|
+
if queryHits:
|
|
35
|
+
confidence += min(0.20, 0.05 * len(queryHits))
|
|
36
|
+
reasons.append("canonicalQueryMatch")
|
|
37
|
+
if "picux" in item.source.url.lower():
|
|
38
|
+
confidence += 0.12
|
|
39
|
+
reasons.append("officialSource")
|
|
40
|
+
if negativeMatches:
|
|
41
|
+
confidence -= 0.35
|
|
42
|
+
reasons.append("harnessMention")
|
|
43
|
+
else:
|
|
44
|
+
confidence = 0.0
|
|
45
|
+
reasons.append("harnessCollision")
|
|
46
|
+
|
|
47
|
+
confidence = max(0.0, min(1.0, round(confidence, 3)))
|
|
48
|
+
launchable = LAUNCH_DOMAINS if entity in {SignalEntity.PICUX, SignalEntity.EXTERNAL_APP, SignalEntity.LEGACY_SWARM} else ()
|
|
49
|
+
return SignalAnalysis(
|
|
50
|
+
signalId=item.signalId,
|
|
51
|
+
entity=entity,
|
|
52
|
+
confidence=confidence,
|
|
53
|
+
matches=matches,
|
|
54
|
+
negativeMatches=negativeMatches,
|
|
55
|
+
reasons=tuple(dict.fromkeys(reasons)),
|
|
56
|
+
query=item.query,
|
|
57
|
+
source=item.source,
|
|
58
|
+
launchableDomains=launchable,
|
|
59
|
+
approvalRequired=True,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def score_signal(signal: CommunitySignal | dict[str, object]) -> SignalAnalysis:
|
|
64
|
+
return scoreSignal(signal)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Storage primitives."""
|
|
2
|
+
|
|
3
|
+
from .agents import AgentBook
|
|
4
|
+
from .cases import CaseBook
|
|
5
|
+
from .channels import ChannelBook
|
|
6
|
+
from .connectors import ConnectorBook
|
|
7
|
+
from .envelopes import EnvelopeBook
|
|
8
|
+
from .events import EventBook, EventDeliveryBook, EventSubscriptionBook
|
|
9
|
+
from .escrows import EscrowBook
|
|
10
|
+
from .keyspace import Keyspace
|
|
11
|
+
from .mandates import MandateBook
|
|
12
|
+
from .portals import PortalBook
|
|
13
|
+
from .postgres import PicuxPostgresStore
|
|
14
|
+
from .providers import LocalProviderBook
|
|
15
|
+
from .proxy import ProxyBook
|
|
16
|
+
from .receipts import ReceiptBook
|
|
17
|
+
from .signals import SignalBook
|
|
18
|
+
from .tasks import TaskBook, taskFromObj, taskView
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"AgentBook",
|
|
22
|
+
"CaseBook",
|
|
23
|
+
"ChannelBook",
|
|
24
|
+
"ConnectorBook",
|
|
25
|
+
"EnvelopeBook",
|
|
26
|
+
"EventBook",
|
|
27
|
+
"EventDeliveryBook",
|
|
28
|
+
"EventSubscriptionBook",
|
|
29
|
+
"EscrowBook",
|
|
30
|
+
"Keyspace",
|
|
31
|
+
"MandateBook",
|
|
32
|
+
"PortalBook",
|
|
33
|
+
"PicuxPostgresStore",
|
|
34
|
+
"LocalProviderBook",
|
|
35
|
+
"ProxyBook",
|
|
36
|
+
"ReceiptBook",
|
|
37
|
+
"SignalBook",
|
|
38
|
+
"TaskBook",
|
|
39
|
+
"taskFromObj",
|
|
40
|
+
"taskView",
|
|
41
|
+
]
|
picux/storage/agents.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import copy
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AgentBook:
|
|
8
|
+
"""Agent capability registry storage with optional durable backing."""
|
|
9
|
+
|
|
10
|
+
def __init__(self, *, backing: Any | None = None) -> None:
|
|
11
|
+
self.backing = backing
|
|
12
|
+
self._agents: dict[str, dict[str, Any]] = {}
|
|
13
|
+
|
|
14
|
+
def saveAgent(self, agent: dict[str, Any]) -> dict[str, Any]:
|
|
15
|
+
agentId = str(agent.get("agentId", "") or "")
|
|
16
|
+
if not agentId:
|
|
17
|
+
return {"ok": False, "error": "missing:agentId"}
|
|
18
|
+
stored = copy.deepcopy(agent)
|
|
19
|
+
self._agents[agentId] = stored
|
|
20
|
+
if self._backingEnabled() and hasattr(self.backing, "upsertAgent"):
|
|
21
|
+
self.backing.upsertAgent(stored)
|
|
22
|
+
return {"ok": True, "agentId": agentId}
|
|
23
|
+
|
|
24
|
+
def getAgent(self, agentId: str) -> dict[str, Any]:
|
|
25
|
+
agentId = str(agentId or "")
|
|
26
|
+
agent = self._agents.get(agentId)
|
|
27
|
+
if agent is None and self._backingEnabled() and hasattr(self.backing, "fetchAgent"):
|
|
28
|
+
agent = self.backing.fetchAgent(agentId)
|
|
29
|
+
if agent:
|
|
30
|
+
self._agents[agentId] = copy.deepcopy(agent)
|
|
31
|
+
if not agent:
|
|
32
|
+
return {"ok": False, "error": "agentNotFound", "agentId": agentId}
|
|
33
|
+
return {"ok": True, "agent": copy.deepcopy(agent)}
|
|
34
|
+
|
|
35
|
+
def listAgents(self) -> dict[str, Any]:
|
|
36
|
+
if self._backingEnabled() and hasattr(self.backing, "listAgents"):
|
|
37
|
+
for agent in self.backing.listAgents():
|
|
38
|
+
agentId = str(agent.get("agentId", "") or "")
|
|
39
|
+
if agentId:
|
|
40
|
+
self._agents[agentId] = copy.deepcopy(agent)
|
|
41
|
+
agents = [
|
|
42
|
+
copy.deepcopy(agent)
|
|
43
|
+
for agent in sorted(self._agents.values(), key=lambda item: str(item.get("agentId", "")))
|
|
44
|
+
]
|
|
45
|
+
return {"ok": True, "agents": agents}
|
|
46
|
+
|
|
47
|
+
def _backingEnabled(self) -> bool:
|
|
48
|
+
if self.backing is None:
|
|
49
|
+
return False
|
|
50
|
+
return bool(getattr(self.backing, "enabled", True))
|