service-bridge 2.0.0-alpha.4 → 2.0.0-alpha.6

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 CHANGED
@@ -41,6 +41,7 @@ You declare what your service handles and what it calls. ServiceBridge does the
41
41
 
42
42
  - [Install](#install)
43
43
  - [AI coding skill](#ai-coding-skill)
44
+ - [CLI](#cli)
44
45
  - [Why ServiceBridge](#why-servicebridge)
45
46
  - [Use cases](#use-cases)
46
47
  - [Quick start](#quick-start)
@@ -110,6 +111,18 @@ Restart the agent so it loads the skill. Source and contents: [`node/skill/`](ht
110
111
 
111
112
  ---
112
113
 
114
+ ## CLI
115
+
116
+ The runtime ships with `sb`, a command-line client for managing services, traces, events, jobs, workflows, alerts and settings. It comes with the runtime image — there is no separate install — so a running runtime already has it at `/usr/local/bin/sb`. Use `docker exec <container> sb …` or the host binary, and pass `-o json` to get machine-readable output for AI agents. Check it with:
117
+
118
+ ```sh
119
+ sb version
120
+ ```
121
+
122
+ Full command reference: **[servicebridge.dev/#docs/cli](https://servicebridge.dev/#docs/cli)**.
123
+
124
+ ---
125
+
113
126
  ## Why ServiceBridge
114
127
 
115
128
  Microservices rarely fail because of business logic. They fail in the gaps *between* services — the broker that dropped a message, the workflow engine nobody fully understands, the trace that stops at a service boundary, the mesh config that takes a week to debug. Each gap is another system to run, secure and correlate.
@@ -1,5 +1,5 @@
1
1
  import { Express } from 'express';
2
- import { p as ServiceBridge } from '../../service-bridge-Bgt4ciRB.js';
2
+ import { p as ServiceBridge } from '../../service-bridge-DGZXGuhl.js';
3
3
  import '@grpc/grpc-js';
4
4
  import '@bufbuild/protobuf/wire';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { FastifyPluginAsync } from 'fastify';
2
- import { v as OpHandle, p as ServiceBridge } from '../../service-bridge-Bgt4ciRB.js';
2
+ import { v as OpHandle, p as ServiceBridge } from '../../service-bridge-DGZXGuhl.js';
3
3
  import '@grpc/grpc-js';
4
4
  import '@bufbuild/protobuf/wire';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { p as ServiceBridge } from '../../service-bridge-Bgt4ciRB.js';
2
+ import { p as ServiceBridge } from '../../service-bridge-DGZXGuhl.js';
3
3
  import '@grpc/grpc-js';
4
4
  import '@bufbuild/protobuf/wire';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AdvertiseConfig, C as CallOpts, a as CatchupPolicy, b as ConnectedEvent, c as CronTrigger, D as DeclaredDep, d as DelayedTrigger, e as DisconnectedEvent, E as EventDomain, I as Identity, f as IntervalTrigger, J as JobDomain, g as JobHandler, h as JobHandlerCtx, i as JobOpts, M as MethodDescriptor, j as MethodType, O as OverlapPolicy, P as PolicyViolationEvent, k as PublishOpts, R as ReconnectingEvent, l as RetryOpts, m as RetryPolicy, n as RpcDomain, o as RpcHandlerOpts, S as SchemaSpec, p as ServiceBridge, q as ServiceBridgeError, r as ServiceBridgeOptions, s as ServiceDeps, T as Trigger, t as TypedClient, W as WorkflowDomain, u as WorkflowHandlerOpts } from './service-bridge-Bgt4ciRB.js';
1
+ export { A as AdvertiseConfig, C as CallOpts, a as CatchupPolicy, b as ConnectedEvent, c as CronTrigger, D as DeclaredDep, d as DelayedTrigger, e as DisconnectedEvent, E as EventDomain, I as Identity, f as IntervalTrigger, J as JobDomain, g as JobHandler, h as JobHandlerCtx, i as JobOpts, M as MethodDescriptor, j as MethodType, O as OverlapPolicy, P as PolicyViolationEvent, k as PublishOpts, R as ReconnectingEvent, l as RetryOpts, m as RetryPolicy, n as RpcDomain, o as RpcHandlerOpts, S as SchemaSpec, p as ServiceBridge, q as ServiceBridgeError, r as ServiceBridgeOptions, s as ServiceDeps, T as Trigger, t as TypedClient, W as WorkflowDomain, u as WorkflowHandlerOpts } from './service-bridge-DGZXGuhl.js';
2
2
  import '@grpc/grpc-js';
3
3
  import '@bufbuild/protobuf/wire';
4
4
 
package/dist/index.js CHANGED
@@ -14599,8 +14599,7 @@ var ServiceBridge = class {
14599
14599
  async connect(attempt) {
14600
14600
  if (this.stopped) return;
14601
14601
  try {
14602
- const key = parseBootstrapKey(this.rawKey);
14603
- const result = await this.opts.provisionFn(this.url, key);
14602
+ const result = this.reusableProvision() ?? await this.opts.provisionFn(this.url, parseBootstrapKey(this.rawKey));
14604
14603
  await this.openSession(result, attempt);
14605
14604
  } catch (err) {
14606
14605
  const sbErr = new ServiceBridgeError("provision", err);
@@ -14612,6 +14611,21 @@ var ServiceBridge = class {
14612
14611
  this.scheduleReconnect(attempt + 1, sbErr.message);
14613
14612
  }
14614
14613
  }
14614
+ /**
14615
+ * Returns the cached provision when its leaf cert is still comfortably valid
14616
+ * (more than certRefreshLeadMs remaining), so a reconnect reuses the existing
14617
+ * identity instead of re-running the Bootstrap argon2 handshake. Returns null
14618
+ * on the first connect or when the cert is near expiry — the caller then does
14619
+ * a fresh Provision.
14620
+ */
14621
+ reusableProvision() {
14622
+ const prov = this.lastProvision;
14623
+ if (!prov) return null;
14624
+ const now = BigInt(Math.floor(Date.now() / 1e3));
14625
+ const remainingMs = Number(prov.notAfterUnix - now) * 1e3;
14626
+ if (remainingMs <= this.opts.certRefreshLeadMs) return null;
14627
+ return prov;
14628
+ }
14615
14629
  async openSession(prov, attempt) {
14616
14630
  const creds = this.buildMTLSCredentials(prov);
14617
14631
  const client = this.opts.clientFactory(this.url, creds);