@withgateway/sdk 0.1.19 → 0.2.0
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 +141 -2
- package/dist/cli.js +8677 -1320
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +8683 -1327
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1005 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +969 -47
- package/dist/index.mjs.map +1 -1
- package/dist/tracing/index.js +9 -2
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +9 -2
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/worlds/index.d.mts +738 -28
- package/dist/worlds/index.d.ts +738 -28
- package/dist/worlds/index.js +966 -51
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +960 -45
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +9 -2
- package/runtime/gatewaysdk/__init__.py +0 -0
- package/runtime/gatewaysdk/environment/__init__.py +108 -0
- package/runtime/gatewaysdk/environment/_bundle.py +281 -0
- package/runtime/gatewaysdk/environment/_harbor.py +276 -0
- package/runtime/gatewaysdk/environment/_materialize.py +97 -0
- package/runtime/gatewaysdk/environment/_tar.py +33 -0
- package/runtime/gatewaysdk/environment/_world.py +346 -0
- package/runtime/gatewaysdk/environment/core.py +527 -0
- package/runtime/gatewaysdk/environment/errors.py +58 -0
- package/runtime/gatewaysdk/environment/runtime.py +150 -0
- package/runtime/gatewaysdk/environment/schema/__init__.py +35 -0
- package/runtime/gatewaysdk/environment/schema/__main__.py +225 -0
- package/runtime/gatewaysdk/environment/schema/_slack_fidelity.py +116 -0
- package/runtime/gatewaysdk/environment/schema/_slack_scenario.py +183 -0
- package/runtime/gatewaysdk/environment/schema/api.py +1628 -0
- package/runtime/gatewaysdk/environment/schema/batch.py +755 -0
- package/runtime/gatewaysdk/environment/schema/compiler.py +615 -0
- package/runtime/gatewaysdk/environment/schema/conform.py +428 -0
- package/runtime/gatewaysdk/environment/schema/connector.py +777 -0
- package/runtime/gatewaysdk/environment/schema/connectors/apple-business-manager/handlers.py +17 -0
- package/runtime/gatewaysdk/environment/schema/connectors/apple-business-manager/parity.json +28 -0
- package/runtime/gatewaysdk/environment/schema/connectors/apple-business-manager/provenance.json +233 -0
- package/runtime/gatewaysdk/environment/schema/connectors/apple-business-manager/scope.toml +112 -0
- package/runtime/gatewaysdk/environment/schema/connectors/apple-business-manager/world.json +1380 -0
- package/runtime/gatewaysdk/environment/schema/connectors/base.json +28 -0
- package/runtime/gatewaysdk/environment/schema/connectors/custom/handlers.py +18 -0
- package/runtime/gatewaysdk/environment/schema/connectors/custom/world.json +123 -0
- package/runtime/gatewaysdk/environment/schema/connectors/github/handlers.py +81 -0
- package/runtime/gatewaysdk/environment/schema/connectors/github/parity.json +37 -0
- package/runtime/gatewaysdk/environment/schema/connectors/github/provenance.json +134 -0
- package/runtime/gatewaysdk/environment/schema/connectors/github/scope.toml +158 -0
- package/runtime/gatewaysdk/environment/schema/connectors/github/world.json +5869 -0
- package/runtime/gatewaysdk/environment/schema/connectors/google-calendar/handlers.py +23 -0
- package/runtime/gatewaysdk/environment/schema/connectors/google-calendar/world.json +209 -0
- package/runtime/gatewaysdk/environment/schema/connectors/google-drive/handlers.py +18 -0
- package/runtime/gatewaysdk/environment/schema/connectors/google-drive/world.json +286 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/handlers.py +34 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/parity.json +49 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/provenance.json +181 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/scope.toml +128 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jamf/world.json +2218 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jira/handlers.py +28 -0
- package/runtime/gatewaysdk/environment/schema/connectors/jira/world.json +389 -0
- package/runtime/gatewaysdk/environment/schema/connectors/kandji/handlers.py +38 -0
- package/runtime/gatewaysdk/environment/schema/connectors/kandji/parity.json +29 -0
- package/runtime/gatewaysdk/environment/schema/connectors/kandji/provenance.json +152 -0
- package/runtime/gatewaysdk/environment/schema/connectors/kandji/scope.toml +120 -0
- package/runtime/gatewaysdk/environment/schema/connectors/kandji/world.json +765 -0
- package/runtime/gatewaysdk/environment/schema/connectors/linear/handlers.py +20 -0
- package/runtime/gatewaysdk/environment/schema/connectors/linear/world.json +363 -0
- package/runtime/gatewaysdk/environment/schema/connectors/microsoft-teams/fidelity.json +45 -0
- package/runtime/gatewaysdk/environment/schema/connectors/microsoft-teams/handlers.py +1 -0
- package/runtime/gatewaysdk/environment/schema/connectors/microsoft-teams/provenance.json +851 -0
- package/runtime/gatewaysdk/environment/schema/connectors/microsoft-teams/scope.md +231 -0
- package/runtime/gatewaysdk/environment/schema/connectors/microsoft-teams/teams-types.json +1710 -0
- package/runtime/gatewaysdk/environment/schema/connectors/microsoft-teams/world.json +858 -0
- package/runtime/gatewaysdk/environment/schema/connectors/netsuite/handlers.py +32 -0
- package/runtime/gatewaysdk/environment/schema/connectors/netsuite/parity.json +50 -0
- package/runtime/gatewaysdk/environment/schema/connectors/netsuite/provenance.json +137 -0
- package/runtime/gatewaysdk/environment/schema/connectors/netsuite/scope.toml +78 -0
- package/runtime/gatewaysdk/environment/schema/connectors/netsuite/world.json +16243 -0
- package/runtime/gatewaysdk/environment/schema/connectors/salesforce/handlers.py +806 -0
- package/runtime/gatewaysdk/environment/schema/connectors/salesforce/parity.json +46 -0
- package/runtime/gatewaysdk/environment/schema/connectors/salesforce/provenance.json +143 -0
- package/runtime/gatewaysdk/environment/schema/connectors/salesforce/scope.toml +174 -0
- package/runtime/gatewaysdk/environment/schema/connectors/salesforce/world.json +4695 -0
- package/runtime/gatewaysdk/environment/schema/connectors/slack/MODEL.md +236 -0
- package/runtime/gatewaysdk/environment/schema/connectors/slack/capabilities.json +1039 -0
- package/runtime/gatewaysdk/environment/schema/connectors/slack/handlers.py +762 -0
- package/runtime/gatewaysdk/environment/schema/connectors/slack/parity.json +65 -0
- package/runtime/gatewaysdk/environment/schema/connectors/slack/provenance.json +294 -0
- package/runtime/gatewaysdk/environment/schema/connectors/slack/scope.toml +44 -0
- package/runtime/gatewaysdk/environment/schema/connectors/slack/world.json +4993 -0
- package/runtime/gatewaysdk/environment/schema/connectors/workday/handlers.py +75 -0
- package/runtime/gatewaysdk/environment/schema/connectors/workday/parity.json +36 -0
- package/runtime/gatewaysdk/environment/schema/connectors/workday/provenance.json +179 -0
- package/runtime/gatewaysdk/environment/schema/connectors/workday/scope.toml +180 -0
- package/runtime/gatewaysdk/environment/schema/connectors/workday/world.json +806 -0
- package/runtime/gatewaysdk/environment/schema/data.py +593 -0
- package/runtime/gatewaysdk/environment/schema/extract.py +263 -0
- package/runtime/gatewaysdk/environment/schema/host.py +2407 -0
- package/runtime/gatewaysdk/environment/schema/host_surfaces.py +275 -0
- package/runtime/gatewaysdk/environment/schema/platform.py +1272 -0
- package/runtime/gatewaysdk/environment/schema/scaffold.py +250 -0
- package/runtime/gatewaysdk/environment/schema/skill.py +118 -0
- package/runtime/gatewaysdk/environment/schema/skills/agents/connector-template-author.md +202 -0
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/CONNECTORS.md +331 -0
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/CONVENTIONS.md +100 -0
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +313 -0
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +223 -0
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +293 -0
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +390 -0
- package/runtime/gatewaysdk/environment/schema/slack.py +757 -0
- package/runtime/gatewaysdk/environment/schema/snapshot.py +479 -0
- package/runtime/gatewaysdk/environment/schema/store.py +904 -0
- package/runtime/gatewaysdk/environment/schema/tasks.py +525 -0
- package/runtime/gatewaysdk/environment/schema/tools_world.py +322 -0
- package/runtime/gatewaysdk/environment/schema/validation.py +577 -0
- package/runtime/gatewaysdk/environment/schema/worker.py +78 -0
- package/runtime/gatewaysdk/environment/schema/workers.py +500 -0
- package/runtime/gatewaysdk/environment/schema/world_tests.py +336 -0
- package/skills/agents/connector-template-author.md +202 -0
- package/skills/connector-schema-authoring/CONNECTORS.md +331 -0
- package/skills/connector-schema-authoring/CONVENTIONS.md +100 -0
- package/skills/connector-schema-authoring/SKILL.md +313 -0
- package/skills/world-data-ingestion/ROWS.md +223 -0
- package/skills/world-data-ingestion/SKILL.md +293 -0
- package/skills/worlds-getting-started/SKILL.md +390 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"""Slack collaboration scenarios and read-only baseline preservation grading."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from .validation import encoded
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _literal(value):
|
|
9
|
+
return "'" + value.replace("'", "''") + "'"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _preservation(entities, mutations, parent):
|
|
13
|
+
"""Compare each baseline entity as a set with fixed, authorized row deltas.
|
|
14
|
+
|
|
15
|
+
VALUES has no per-row compound SELECT or AND chain. One EXCEPT comparison
|
|
16
|
+
per nonempty entity detects changed/missing payloads; exact counts plus the
|
|
17
|
+
task's semantic predicates constrain additional rows. The literal baseline
|
|
18
|
+
is bundle-owned SQL data, never a writable table or a second state store.
|
|
19
|
+
"""
|
|
20
|
+
expected = {entity: [] for entity in sorted(entities)}
|
|
21
|
+
for mutation in mutations:
|
|
22
|
+
entity, value = mutation["entity"], dict(mutation["value"])
|
|
23
|
+
if entity == "slack_messages" and value == parent:
|
|
24
|
+
value.pop("reply_count", None)
|
|
25
|
+
value.pop("latest_reply", None)
|
|
26
|
+
if (
|
|
27
|
+
entity == "slack_reaction_summaries"
|
|
28
|
+
and value["channel_id"] == parent["channel_id"]
|
|
29
|
+
and value["message_ts"] == parent["ts"]
|
|
30
|
+
and value["name"] == "white_check_mark"
|
|
31
|
+
):
|
|
32
|
+
value["count"] += 1
|
|
33
|
+
expected[entity].append(json.dumps(value, sort_keys=True, separators=(",", ":"), ensure_ascii=False))
|
|
34
|
+
counts = {entity: len(rows) for entity, rows in expected.items()}
|
|
35
|
+
for entity in ("slack_messages", "slack_message_threads", "slack_reaction_users"):
|
|
36
|
+
counts[entity] += 1
|
|
37
|
+
if not any(
|
|
38
|
+
m["entity"] == "slack_reaction_summaries"
|
|
39
|
+
and m["value"]["channel_id"] == parent["channel_id"]
|
|
40
|
+
and m["value"]["message_ts"] == parent["ts"]
|
|
41
|
+
and m["value"]["name"] == "white_check_mark"
|
|
42
|
+
for m in mutations
|
|
43
|
+
):
|
|
44
|
+
counts["slack_reaction_summaries"] += 1
|
|
45
|
+
ctes, comparisons = [], []
|
|
46
|
+
for index, (entity, rows) in enumerate(expected.items()):
|
|
47
|
+
if rows:
|
|
48
|
+
name = f"expected_{index}"
|
|
49
|
+
values = ",\n".join(f"({_literal(row)})" for row in rows)
|
|
50
|
+
ctes.append(f"{name}(payload) AS (VALUES\n{values})")
|
|
51
|
+
actual = "json(payload)"
|
|
52
|
+
if entity == "slack_messages":
|
|
53
|
+
actual = (
|
|
54
|
+
f"CASE WHEN channel_id = {_literal(parent['channel_id'])} AND ts = {_literal(parent['ts'])} "
|
|
55
|
+
"THEN json_remove(payload, '$.reply_count', '$.latest_reply') ELSE json(payload) END"
|
|
56
|
+
)
|
|
57
|
+
comparisons.append(f'NOT EXISTS (SELECT payload FROM {name} EXCEPT SELECT {actual} FROM "{entity}")')
|
|
58
|
+
comparisons.append(f'(SELECT COUNT(*) FROM "{entity}") = {counts[entity]}')
|
|
59
|
+
return "WITH " + ",\n".join(ctes), "\nAND ".join(comparisons)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _scenario(destination, evidence, batch, *, entities):
|
|
63
|
+
synthetic = evidence.get("synthetic") is True
|
|
64
|
+
messages = [m["value"] for m in batch["mutations"] if m["entity"] == "slack_messages"]
|
|
65
|
+
replies = {
|
|
66
|
+
(m["value"]["channel_id"], m["value"]["reply_ts"])
|
|
67
|
+
for m in batch["mutations"]
|
|
68
|
+
if m["entity"] == "slack_message_threads"
|
|
69
|
+
}
|
|
70
|
+
member_channels = {
|
|
71
|
+
m["value"]["channel_id"]
|
|
72
|
+
for m in batch["mutations"]
|
|
73
|
+
if m["entity"] == "slack_memberships" and m["value"]["user_id"] == evidence["principal"]["user_id"]
|
|
74
|
+
}
|
|
75
|
+
writable = {
|
|
76
|
+
m["value"]["id"]
|
|
77
|
+
for m in batch["mutations"]
|
|
78
|
+
if m["entity"] == "slack_channels" and not m["value"].get("is_archived") and not m["value"].get("is_frozen")
|
|
79
|
+
}
|
|
80
|
+
acknowledged = {
|
|
81
|
+
(m["value"]["channel_id"], m["value"]["message_ts"])
|
|
82
|
+
for m in batch["mutations"]
|
|
83
|
+
if m["entity"] == "slack_reaction_users"
|
|
84
|
+
and m["value"]["name"] == "white_check_mark"
|
|
85
|
+
and m["value"]["user_id"] == evidence["principal"]["user_id"]
|
|
86
|
+
}
|
|
87
|
+
roots = [
|
|
88
|
+
m
|
|
89
|
+
for m in messages
|
|
90
|
+
if (m["channel_id"], m["ts"]) not in replies | acknowledged
|
|
91
|
+
and m["channel_id"] in member_channels & writable
|
|
92
|
+
and m.get("subtype") not in ("channel_join", "channel_leave")
|
|
93
|
+
]
|
|
94
|
+
if not roots:
|
|
95
|
+
(destination / "verifiers/state_present.sql").unlink(missing_ok=True)
|
|
96
|
+
return {"status": "unavailable", "reason": "No observed member conversation with a persistent root message."}
|
|
97
|
+
parent = next(
|
|
98
|
+
(m for m in roots if m["channel_id"] == "CGENERAL" and m["ts"] == "1700000000.000000000000000001"), roots[0]
|
|
99
|
+
)
|
|
100
|
+
text = (
|
|
101
|
+
"Handoff complete: release checklist reviewed; owner Alice; next update 17:00 UTC."
|
|
102
|
+
if synthetic
|
|
103
|
+
else "Review complete: captured workspace handoff acknowledged."
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
w, c, p, actor, body = map(
|
|
107
|
+
_literal,
|
|
108
|
+
(evidence["workspace"]["id"], parent["channel_id"], parent["ts"], evidence["principal"]["user_id"], text),
|
|
109
|
+
)
|
|
110
|
+
baseline, preserved = _preservation(entities, batch["mutations"], parent)
|
|
111
|
+
acknowledgement_count = 1 + sum(
|
|
112
|
+
mutation["value"]["count"]
|
|
113
|
+
for mutation in batch["mutations"]
|
|
114
|
+
if mutation["entity"] == "slack_reaction_summaries"
|
|
115
|
+
and mutation["value"]["channel_id"] == parent["channel_id"]
|
|
116
|
+
and mutation["value"]["message_ts"] == parent["ts"]
|
|
117
|
+
and mutation["value"]["name"] == "white_check_mark"
|
|
118
|
+
)
|
|
119
|
+
sql = f"""-- Read-only set comparisons keep preparation depth independent of record count.
|
|
120
|
+
{baseline}
|
|
121
|
+
SELECT CASE WHEN EXISTS (
|
|
122
|
+
SELECT 1 FROM slack_reaction_users r JOIN slack_reaction_summaries summary
|
|
123
|
+
ON summary.workspace_id = r.workspace_id AND summary.channel_id = r.channel_id
|
|
124
|
+
AND summary.message_ts = r.message_ts AND summary.name = r.name
|
|
125
|
+
WHERE r.workspace_id = {w}
|
|
126
|
+
AND r.channel_id = {c} AND r.message_ts = {p} AND r.user_id = {actor}
|
|
127
|
+
AND r.name = 'white_check_mark'
|
|
128
|
+
AND summary.count = {acknowledgement_count}
|
|
129
|
+
) AND EXISTS (
|
|
130
|
+
SELECT 1 FROM slack_messages m JOIN slack_message_threads t
|
|
131
|
+
ON t.workspace_id = m.workspace_id AND t.channel_id = m.channel_id AND t.reply_ts = m.ts
|
|
132
|
+
JOIN slack_messages parent
|
|
133
|
+
ON parent.workspace_id = t.workspace_id AND parent.channel_id = t.channel_id AND parent.ts = t.parent_ts
|
|
134
|
+
WHERE m.workspace_id = {w} AND m.channel_id = {c} AND t.parent_ts = {p}
|
|
135
|
+
AND m.user = {actor} AND m.text = {body}
|
|
136
|
+
AND parent.reply_count = {parent.get('reply_count', 0) + 1} AND parent.latest_reply = m.ts
|
|
137
|
+
) AND {preserved} THEN 1.0 ELSE 0.0 END;
|
|
138
|
+
"""
|
|
139
|
+
(destination / "verifiers/state_present.sql").unlink(missing_ok=True)
|
|
140
|
+
(destination / "verifiers/handoff_complete.sql").write_text(sql)
|
|
141
|
+
task = (
|
|
142
|
+
f"Find the release-handoff discussion asking for checklist review. Read its thread and associated checklist metadata. Acknowledge the parent with white_check_mark and reply exactly: {text} Keep all other workspace state unchanged."
|
|
143
|
+
if synthetic
|
|
144
|
+
else f"Find and review the captured discussion beginning {parent.get('text', '')[:160]!r}. Read its thread, acknowledge the parent with white_check_mark and reply exactly: {text} Keep other workspace state unchanged."
|
|
145
|
+
)
|
|
146
|
+
discovery = [
|
|
147
|
+
{"tool": "conversations.list", "arguments": {"types": "public_channel,private_channel,im,mpim"}},
|
|
148
|
+
{"tool": "conversations.history", "arguments": {"channel": parent["channel_id"]}},
|
|
149
|
+
{"tool": "conversations.replies", "arguments": {"channel": parent["channel_id"], "ts": parent["ts"]}},
|
|
150
|
+
]
|
|
151
|
+
if synthetic:
|
|
152
|
+
discovery.append({"tool": "files.info", "arguments": {"file": "FCHECKLIST"}})
|
|
153
|
+
return {
|
|
154
|
+
"status": "available",
|
|
155
|
+
"kind": "synthetic" if synthetic else "captured-subset",
|
|
156
|
+
"task": task,
|
|
157
|
+
"target": {"channel": parent["channel_id"], "thread_ts": parent["ts"]},
|
|
158
|
+
"oracle": [
|
|
159
|
+
*discovery,
|
|
160
|
+
{
|
|
161
|
+
"tool": "reactions.add",
|
|
162
|
+
"arguments": {"channel": parent["channel_id"], "timestamp": parent["ts"], "name": "white_check_mark"},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"tool": "chat.postMessage",
|
|
166
|
+
"arguments": {"channel": parent["channel_id"], "thread_ts": parent["ts"], "text": text},
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
"verifier": "handoff_complete",
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def write_scenario(destination, evidence, state, *, entities):
|
|
174
|
+
scenario = _scenario(destination, evidence, state, entities=entities)
|
|
175
|
+
(destination / "scenario.json").write_bytes(encoded(scenario))
|
|
176
|
+
tasks = []
|
|
177
|
+
if scenario["status"] == "available":
|
|
178
|
+
tasks.append({"id": "handoff_complete", "prompt": scenario["task"], "verifier": scenario["verifier"]})
|
|
179
|
+
else:
|
|
180
|
+
(destination / "verifiers/handoff_complete.sql").unlink(missing_ok=True)
|
|
181
|
+
# Both the direct runner and hosted schema session resolve tasks.json. Keep
|
|
182
|
+
# the instruction with the verifier instead of relying on a generic fallback.
|
|
183
|
+
(destination / "tasks.json").write_bytes(encoded(tasks))
|